Общий форумTest: ABBCC Answer: BB It's not that test( I have WA#17 but my prog writes "BB" on this test I had WA on this test. I used manacher algorithm from e-maxx, in realization on site is one mistake, what ruin solution on this test, after correcting i got AC #include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <string> #include <iomanip> #include <set> using namespace std; int main() { int x1, x2, y1, y2, x3, y3, l; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> l; // h = 2/s3 в€љp(p-s3)(p-s1)(p-s2), int a = y1 - y2, b = x2 - x1, c = x1 * y2 - x2 * y1; double s1 = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)), s2 = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)), s3 = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); double p = s1 + s2 + s3; p /= 2; double ans = (2 / s3 * sqrt(p * (p - s3) * (p - s1) * (p - s2))); if (max(s1, s2) * max(s1, s2) > min(s1, s2) * min(s1, s2) + s3 * s3) { ans = min(sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)), sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3))); } if (s3 == 0.0) { ans = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) *(y1 - y3)); } printf("%0.2f\n", max(0.0, ans - l)); printf("%0.2f\n", max(0.0, max(sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)), sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3))) - l)); } k=2 => k-1 = 1. But everything is divisible by 1, what's wrong? Not all numbers could be written in binary number system #include<iostream> #include<cmath> #include<iomanip> #define pi 3.1415926 using namespace std; int main(){ float side,len; cin>>side>>len; if(len>(side/2)*sqrt(2)){ cout<<fixed<<setprecision(3)<<side*side; return 0; } if((side/2)>=len){ cout<<fixed<<setprecision(3)<<len*len*pi; return 0; } float cosx=(side/2)/len; float sinx=sqrt(1-cosx*cosx); float cosA=2*sinx*cosx; float theta=acos(cosA); cout<<fixed<<setprecision(3)<<len*len*0.5*theta*4+sqrt(len*len-(side/2)*(side/2))*(side/2)*4;
return 0; } qalesan nima uchun o'zbek tilida gapirasiz? GOOD peoples Please help me! I have got WA#5! I used DSU!! My program gives right answer for all my tests! But again WA#5 and I can not found my mistake! I shall wait advices or tests! Thank you advance!!! I have got AC!!! =) What test you used to check it? 4 4 1 2 1 2 2 3 3 4 3 1 2 3 good luck!!! just consider this condiction: 2 A\A B\A the correct output is A A B A but if you are mistaken, you will output A A Of course, folders on different depths (or in different subtrees) can have equal names. (look at disk tree on your computer). Edited by author 30.10.2004 22:38 Why couldn't it be : B A A ?? All the given directory addresses start from same common root Please help me. TLE #39 EDIT: GOT AC how The least prime divider in tests is less than 1.1E6 (but checking till 8E7 will still got AC) I think that most people trying to solve this problem will try to deal with two problems, they are: 1. How to calculate a[n] fast? 2. How to find those n that a[n] is the maximum in [1...n]? Here is my method. 1. Calculating a[n] (without calculating a[1...n-1]). Directly calculation will lead to a long time. But, after some observation, I found that: a[4n] = a[n] a[4n + 1] = a[2n] + a[2n + 1] = 2a[n] + a[n + 1] a[4n + 2] = a[n] + a[n + 1] a[4n + 3] = a[n] + 2a[n + 1] So, a[4n] to a[4n + 3] could be presented as the linear form of a[n] and a[n + 1]. We will soon realise that, a[2^k n] to a[2^k n + (2^k - 1)] could also be presented as linear form of a[n] and a[n + 1]. So, pre-calculation is done to calculate all the linear forms of a[65536n] to a[65536n + 65535]. This will take about O(65536 * 2) time. After this pre-calc, calculation for any number K will go very fast. 2. Finding the maximum. After listing some of the 'maximum index', we found that: 1 3 5 9 11 19 21 35 37 43 ...... Maybe my math is not so good, so I could not find so useful properties in the array, but I noticed one thing: ------------------------------------------------------------------------------------------ Every 'maximunm index' could be presented as its max 2-power and some former 'maximum index'. ------------------------------------------------------------------------------------------ Sorry for my poor English, let's take a look at the examples: 1 3 = 2 + 1 5 = 4 + 1 9 = 8 + 1 11 = 8 + 3 19 = 16 + 3 21 = 16 + 5 35 = 32 + 3 37 = 32 + 5 43 = 32 + 11 ...... So, we just need to use every 2^k number to ITERATE the list of 'maximum index'. As the list is of size O(Log N), the algo runs quite fast. With above methods, I got AC in 0.046 sec. Well, if my algo is too stupid for you, don't hesitate to post your algo here. Have fun and good luck. #include <iostream> using namespace std; char paper[4][4], pass[4][4],rPass[16],TempPaper[4][4]; int v, i, j; void check(char paper[4][4], char pass[4][4]) { for (int j = 0; j < 4; j++)// X/. { for (int i = 0; i < 4; i++) { if (paper[j][i] == 'X') { rPass[v] = pass[j][i]; v++; } } } } int main() { for (int j = 0; j < 4; j++) //paper cin { for (int i = 0; i < 4; i++) { cin >> paper[j][i]; } } for (int j = 0; j < 4; j++)//зашифрованый пароль { for (int i = 0; i < 4; i++) { cin >> pass[j][i]; } } for (int j = 0; j < 4; j++)//temp { for (int i = 0; i < 4; i++) { TempPaper[j][i] = paper[j][i]; } } check(paper, pass); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { int t=0, y; if (j == 0) { int u = 3; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[0][y]; t++; } } if (j == 1) { int u = 2; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[1][y]; t++; } } if (j == 2) { int u = 1; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[2][y]; t++; } } if (j == 3) { int u = 0; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[3][y]; t++; } } } check(paper, pass); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { TempPaper[j][i] = paper[j][i]; } } } return 0; } It contains more than 20 zeroes. Totally discouraged with it. Please give some test. Got AC. There was an unobvious but very stupid bug... I used a simple algo... I am just checking 3 consecutive numbers... If any 3 consecutive numbers from the given numbers are like this, n1>n3>n2 (mid one is the smallest, first one is the largest and the last one lies in between these two values) , then the sequence is invalid (Cheater) ... else , I print "Not a proof" ... Is my algo ok? If so, then please help me with some test cases... I have tried all the test cases found in the discussions and my program passed all of them... Thanks a lot for your answer. I haven't heard about "Process Modelling" ... I'll look into it asap. And my algo that I used is wrong actually. It fails in this type of cases... 4 3 1 4 2 Correct answer is "Cheater", but my program shows "Not a proof"... I wonder how it passed 22 tests... 0_O Thanks again... :) «I haven't heard about "Process Modelling" ... I'll look into it asap.» Well, it's simple. Basically you just put balls into array in a proper order, and when the last ball is a current takeout request, you take it out of the array and move to next takeout request, and repeat if needed. If at certain point the takeout ball is not the one you expect, the answer is cheater. Good luck~ #include<bits/stdc++.h> using namespace std; int main(void) { int t_h,s_h,pb; while(cin>>pb) { s_h=0,t_h=0; if(pb>=1 && pb<=11) { s_h=12-pb; t_h=s_h*45; if(t_h<=240) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } return 0; } #include <stdio.h> int main() { unsigned long long int a; scanf("%llu", &a); if (a/7!=0) printf("%llu\n", a%7); else if (a < 7) printf("%d\n", a); } I`m sure that written algo is correct, but I might make stupid mistake... My solutions can pass all my tests and my friends` also. Please, give me some tricky tests! Thanks a lot! 2 2 0 1 2 0 * 2 1 1 0 2 3 0 answer 5 Here are some tests: TEST : 10 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 answer 100 TEST: 1 3 1 10 0 2 -5 0 3 -1000 0 answer -1000 Here are some tests: TEST: 1 3 1 10 0 2 -5 0 3 -1000 0 answer -1000 I think this test is wrong, because we have only 1 planet on the 0th level, So it should be: 1 3 1 10 0 1 -5 0 1 -1000 0 I keep getting non-zero return from WA #9 (meaning some of my scanf() fails) Could you please forward WA #9 problem so that I can check parsing is proper? Thank you, Test #9 probably contains upper limit case, when there are max possible levels with max planets in each, I can suggest you to check your array sizes. I also got WA #9 after setting wrong integer value for "unreachable" planets - I've set it too small and it affected the result at this test You're right... After changing the values to a higher value for the unreachable nodes, I got AC. Thanks. import java.io.*; import java.util.*; public class task { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); int t; if(n>=1 && k<=1000) { if((int) (n * 2.0 / k) == (n * 2.0 / k)) t = (int) (n * 2.0 / k); else t = 1 + (int) (n * 2.0 / k); out.print(t);
} out.flush(); } } Братан эту задачку на 1 вывод решить можно) зачем тебе эти условия Edited by author 29.10.2015 01:41 Я одного не пойму, как можно обжарить 3 бифа с обеих сторон за 3 минуты, если влазит на сковороду всего 2 шт???))) На первой минуте жаришь первые 2шт с одной стороны, на второй их же со второй. На третей минуте последний биф 1 сторона 4я минута 2я сторона 3го бифа!!. В итоге правильный ответ 4 минуты, а не 3 как написано в примерах. Изи. Смотри 1 и 2 это первые и вторые стороны бифов. B это номер бифа. Разделю их точкой первая минута: 1.1 1.2 вторая минута: 2.1 1.3 третья минута: 2.2 2.3 Я тоже также думал, пока не прочитал в дискуссии: http://acm.timus.ru/forum/thread.aspx?id=36182&upd=636324641214598077 1-я минута - Жарится одна сторона двух стейков.(1-я сторона) 2-я минута - Жарится один из первых стейков(2-я сторона) + третий стейк(1-я сторона) 3-я минута - Жарится второй из первых стейков(2-я сторона) + третий стейк(2-я сторона) #include <iostream> #include <stdio.h> #include <vector> using namespace std; class Place { public: char x; int y; bool isOnboard() { if (x < 'a' || x > 'h' || y < 1 || y > 8) return false; return true; } Place(char x, int y) { this->x = x; this->y = y; } }; int main(int argc, const char * argv[]) { int N; cin >> N; vector<Place> places; for (int i = 0; i < N; i++) { char x; int y; cin.get(x); if (x == '\n') { i--; continue; } cin >> y; Place place (x, y); places.push_back(place); } for (int i = 0; i < N; i++) { Place place = places[i]; int moves = 0; //left 2 up 1 place.x -= 2; place.y -= 1; moves += place.isOnboard(); //left 2 down 1 place.y += 2; moves += place.isOnboard(); //right 2 down 1 place.x += 4; moves += place.isOnboard(); //right 2 up 1 place.y -= 2; moves += place.isOnboard(); //right 1 up 2 place.x -= 1; place.y -= 1; moves += place.isOnboard(); //left 1 up 2 place.x -= 2; moves += place.isOnboard(); //left 1 down 2 place.y += 4; moves += place.isOnboard(); //right 1 down 2 place.x += 2; moves += place.isOnboard(); cout << moves << endl; } } |
|