Common BoardYou have to be very careful with scanf. It is wrong to write something like "scanf("%d\n", &n);" It took me a month to find this bug. You have to be very careful with scanf. It is wrong to write something like "scanf("%d\n", &n);" It took me a month to find this bug. To Samsonov Alex: why? please write answer(my mail Dembel12006@yandex.ru) Edited by author 21.01.2007 14:25Check your mail. I also have WA on test #12. Could you tell me what about scanf (cwac@hackermail.com) I have too ... wa12 i have tested all line on wrong simb.. on e>500 ... on #100... can somebody help me... de10@rambler.ru big s! Like many others I also got wa#12. Can you mail me (rddvl@mail.ru) this info about scanf? Thankful in advance. Oh, god :) I should better write it here. The thing is that if you use scanf("%d\n", &N); it reads not only number N and line break but also all whitespace characters after this linebreak. So, for example, it is possible that your program fails here: //some number 3 _1.e6//Space at the beginning of the line 3 It can say that ' 1.e6' is a correct number. Edited by author 27.02.2007 23:10 Edited by author 27.02.2007 23:10 Thanks a lot, but this situation is correctly processed in my program. But I have another question. Is number "1.e6" correct ? I'm talking about it's fractional part. According to problem's notation there shouldn't be numbers with decimal point and without fractional part. What can you say about this? Yes, it's incorrect indeed. My bug :) Thanks for info anyway. some tests: carefully check your program behavior -0.00 0 0 0.000e00000 0 0 0.00 5 0.00000 1e000000000000000000000000000000000012 3 1000000000000.000 -1e-12345678910111213141516 5 0.00000 -1.e-12 3 Not a floating point number 123.23e-12.4 0 Not a floating point number -.12e4 2 -1200.00 123.3e0 12 123.300000000000 12.2e-10 5 0.00000 12.2e+10 3 122000000000.000 12 e3 21 Not a floating point number I fixed all bugs, that i found in forum, but i still got WA on f---g test 12. Anybody! Help me! Mail: mr_ffloyd@mail.ru Edited by author 16.04.2007 19:19 Power can be vary big: as positive as negative! But "It is guaranteed that a length of a result will not exceed 200 symbols." Very good test: 0.0e+1212121332233333333 2 # 0e1212121332233333333 2 # answer: 0.00 =) PS: thank you, PieceOfMeat ! Good test! You have helped me! Edited by author 08.01.2012 05:41 Edited by author 08.01.2012 05:41 I used cin >> N; gets(s); instead of scanf("%d\n", &N); and got AC :) Also, -0.0000010e+6 0 -1 (got me on test 12 and isn't mentioned here) Maybe someone has already written about it, but I didn't find. !!--BE CAREFUL:--!! Test 12 is correct, it has big exponent part like 2E100000000000 10 and answer would look like 0.00..000 the right answer should be 2<many zeros>.<10 zeros> but as it's granted that the output will not exceed 200 symbols, i don't think there will happen to be such inputs. or the maximum output can be a too long to deal with. >>Posted by SkorKNURE October 23, 2008 08:40 >> >>Maybe someone has already written about it, but I didn't >>find. >> >>!!--BE CAREFUL:--!! >> >>Test 12 is correct, it has big exponent part like >>2E100000000000 >>10 >> >>and answer would look like >>0.00..000 Edited by author 20.05.2009 21:33 I had a stupid error... test: 12. 2 # my program`s output was 12.00, should be NAN. Well, i started to store input in array like this ... int [] hatches = new int[n+]; ... After that converted them into double. That ended with WA4 changed to double [] hatches = new double[n+]; and i got ACed. #include<stdio.h> int main() { _int64 f[2005]; int i,j,n,x,y,min,max; _int64 fi,fj,fmax,fmin; scanf("%d",&i); scanf("%lld",&fi); scanf("%d",&j); scanf("%lld",&fj); scanf("%d",&n);
int k; _int64 fib[2100]; fib[0]=0; fib[1]=1; fib[2]=1; for(k=3;k<2100;k++) { fib[k]=fib[k-2]+fib[k-1]; } f[i+1001]=fi; f[j+1001]=fj; if(i<j){min=i;max=j;fmax=fj;fmin=fi;} else {min=j; max=i; fmax=fi; fmin=fj;} x=min-2; y=max-x; f[min-1+1001]=(fmax-fib[y-1]*fmin)/fib[y-2]; for(i=min+1+1001;i<=1000+1001;i++) { f[i]=f[i-1]+f[i-2]; } for(i=0;i<=1000+1001;i++) { if(i==n+1001) { printf("%lld\n",f[i]);
} } return 0; } Sizda tipdan kamchilik. ya'ni __int64 tipi fibanachi sonining (45 - 47 oraliqgacha) elementigacha hisoblay oladi xolos,undan ortig'i si'g'maydi. bundan tashqari fibanachi sonining 2000 - elementi 10^10450 xonali bo'ladi Sizda tipdan kamchilik. ya'ni __int64 tipi fibanachi sonining (45 - 47 oraliqgacha) elementigacha hisoblay oladi xolos,undan ortig'i si'g'maydi. bundan tashqari fibanachi sonining 2000 - elementi 10^10450 xonali bo'ladi Edited by author 07.01.2012 14:05 Edited by author 07.01.2012 01:46 cuz it's very very bad Edited by author 07.01.2012 01:46 people what is the test #1? Usually it's the sample test from the problem description. #include <iostream> #include <string> using namespace std; void main() { string shifr; cin >> shifr; for (int n = 0;n<shifr.length();n++) { for (int i = 0;i<shifr.length()-1;i++) { if(shifr[i]==shifr[i+1]) { shifr.erase(i,2); } } } cout << shifr << endl; } I have got crash on test 2 First of all you will get TLE for your solution. Just use the Stack data structure and insert each characters one by one from the input string by comparing them with the lastly pushed character. If they match, then pop it off that lastly pushed character. Then printout the stack in reverse. That's all :) answer is minimal covering + independ vertexes. Am I rigth? Problem statement was updated: • "All the pieces have distinct coordinates and lie on a table" • "Coordinates should be precise up to 7 digits" New tests have been added. Timelimit was decreased to 3 seconds. Submissions made after contest have been rejudged. This problem suppose O(N^2) solution now. I think there is an O(NlogN) solution But how??? I solved this problem using quadro trees. My solution is about O(N^2*log(N)). What is O(N^2) or O(Nlog(N)) algo? Diagram of Voronoy - is O(n*log(n)) O(n^3) is also acceptable, but it seems to be O(n^2) Edited by author 06.01.2012 03:13 I used BufferedReader and got crash on test 3 without .trim() i used Scanner and all became Ok. But with BufferedReader and .trim() i've got any crashes. It seems that i don't know how to cook it i've got wa on test2. In fact my algo is very simple and a know that this program want another algo but can't understand why this algo don't work... var n,x:int64; s,t:array [1..250000] of char; bool:boolean; i,j:longint; begin readln (n); for i:=1 to n-1 do read (s[i]); readln (s[n]); for i:=1 to n-1 do read (t[i]); readln (t[n]); x:=-1; for i:=1 to n do if s[i]=t[1] then begin bool:=true; for j:=2 to n-i+1 do if s[j+i-1]<>t[j] then begin bool:=false; break; end; if bool then for j:=1 to i-1 do if s[j]<>t[n-i+j+1]then begin bool:=false; break; end; if bool then begin x:=n-i+1; break; end; end; writeln (x); end. Regards Thefox In test 2 strings are equal and you should output 0, not n. Anyway your algorithm gets TLE on test: 250000 aaa...aaa aaa...aab Edited by author 01.10.2011 20:35 I always get WA#10 here is my solution #include <iostream> #include <vector> #include <string> #include <stack> using namespace std; int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","rt",stdin); freopen("output.txt","wt",stdout); #endif string operation; stack <long > znach[1002]; short n; short int x; long y; cin >>n; for (short i=1; i<=n; i++){
cin >> operation;
if(operation=="PUSH"){ cin >> x; cin>>y; znach[x].push(y); }else{ cin >>x; long z=znach[x].top(); cout <<z<<endl; znach[x].pop(); }
} } one who finds a mistake, please write back are you crazy, man? It's not too easy problem as you think.You should write your OWN stack are you crazy, man? It's not too easy problem as you think.You should write your OWN stack @Jew on the space Hey, please be more respectful. He complains about receiving WA not MLE so he has a point. @alex kichkin The problem in your code is that you declared i and n as shorts (which is 2 bytes) but n can be at most 100000 (so 4 bytes is needed). Changing your code with int type for i and n gives correct MLE now. Further on, as Jew on the space suggested, you should develop yourself a stack, more suitable with the problem constraints. Cheers I got TLE on testcase 3 and I know test3 is testing near 10^18. Im using the square root method to solve the problem and the loop starts with the value from the square root function. However for numbers that are close to 10^18, the loop will run approximately 30,000 times and I know this is the problem with my solution. Can anyone tell me some ways that I could use to make the solution faster? btw I'm doing this in C++. Thanks :) Hello, I have a problem with test 6 - can you please give me some similar input and right answer? I read this discuss and I found only something about wrong character problem, so I added testing of it (if there are any not number characters, it ignores them). It didn't help. Thanks and sorry for my English. Edited by author 12.10.2011 18:05 I found a mistake, it was that: if you use java, you must use BigInteger, not just long or double. I hope it will help someone. I'm pretty sure that the test case for 6 is really larger value that will fail if you use Math.sqrt function. Provide your own square root function and you will AC for sure :) input: 6 7 1 2 1 2 3 1 3 2 1 2 1 1 4 5 2 5 6 2 6 4 2 -1 output: 1 2 3 2 many progs answer on this test 4 5 6 am I right? Edited by author 18.03.2009 16:09 Answer is 4 5 6. First, the graph is not orientated, and second, as it is said in the task, "All the numbers x1, …, xk should be different.", so you can't use the second vertex twice. Edited by author 07.10.2009 11:03 as far as I understand right answer is "1 2" ????????????????????????? n=3 and m=7 This is an example test. Please admins correct it ???????????????????????????
Edited by author 07.10.2005 16:30 У меня программа тоже находит такой путь. И я просто к ответу прибавляю всегда 1 Разве путь не : { I also find the program that way. And I just added to the answer is always 1 Is not the way: } 2 1 3 2 2 3 2 4 1 5 2 6 3 7 А пример: {Simple} 2 2 1 1 1 2 11 00 My program returns: 2 0 Right ? Accepted 0.531 Edited by author 03.01.2012 22:24 output “undefined” instead of it. means instead of number or instead of that line? The idea is to find divider for n in set between 2 and 9. If there is no such dividers we'll have answer -1. If yes, we divide n by this divider and do it again, until n isn't equal 1. Realization: #include <iostream> #include <math.h> #include <cstdio> #include <string.h> using namespace std; void main(void) { long long int n; cin>>n; if (n==0) { cout<<"10" ; return; } if (n==1) { cout<<"1"; return; } int *a = new int[14]; for(int i = 0;i<14;i++) { a[i] = 0; } int counter = 13; while(n>1) { for(int j = 9;j>=0; j--) { if (j==1) { cout<<"-1";
return; } if (n%j==0) { a[counter] = j; counter--; n/=j; break; } } } for(int i = counter+1 ;i<14;i++) { cout<<a[i]; } return; } Sorry, for my English and for some unnecessary includes or code=) masalalarni ishlab charchamaylar var a:array[1..100,1..100]OF INTEGER; i,j,n:1..100; t:word; begin read(n); FOR I:=1 TO N DO FOR j:=1 to n do read(a[i,j]); for i:=1 to n do begin t:=0; for j:=i downto 1 do begin t:=t+1; write(a[j,t]); end;end; for i:=2 to n do begin t:=i; for j:=n downto i do begin write(a[j,t]); t:=t+1; end;end; readln;readln; { TODO -oUser -cConsole Main : Insert code here } end. |
|