Common BoardЕсли на паскале в конце выводимой программы поставить "readln;", получите WA1 it says than "the sum of the first three digits....is equal with the sum of nthe last three". In that case 45 first there 4+5+(null)=9 last three 5+4+(null)=9 =>45 is a lucky number!!! that means than there are (at nr 2) 11,12,13,...,99(100-1-10)=89 lucky numbers... Can anyone explain me why they say yhere are only 10 numbers at example 2?? THANX Input is not N but 2N - common length of ticket:) Thus they are ten: 00,11,22,33,44,55,66,77,88,99. you mean than the lucky numbers are the mirror numbers ex: 123454321 1234554321 ???::? yes but not only mirror numbers are the lucky ones, also for ex.: 1234532145 the point is that the sum of digits on the left must be equal to sum of the right side to meet this demand of being lucky qs:If we have the 3 case...wich is the middle? for eg 123 the middle is 12 or only 1(23 or only 3) Edited by author 04.06.2010 21:41 The problem states you are passed an even positive number, so you need not solve it for odd values. I got WA #41, can anyone give me some test case ? Thank you :) Mind the tests 000000 and 999999 999999+1 and 000000-1 don't belong to the definition of ticket i wonder, which part of 999999 or 000000 is greater or less by 1 than the other one? I got WA #4 with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.15e", sum / n); return 0; } WA #5 with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.7e", sum / n); return 0; } WA #6 with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.8e", sum / n); return 0; } AC with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.15e", sum / n); return 0; } But, connecting to the problem statements, "The offset should be printed with at least six digits after decimal point." I'm using pure Monte-Carlo method. Here is my code (C#): [Code deleted by author] I've found my bug... P.S. For the pure Monte-Carlo method it is enough 10^5 points and Double type. Edited by author 13.06.2010 19:25 100 * 100 pts are enough. How to show 6 digits after the point using double/float variable? You can do one of the following ways : 1) fprintf(stdout,"%.6lf ",n) ; or printf("%.6lf",n) ; 2) setprecision( 6 ) ; cout << n ; /* in this way , it won't print out the last zero digits. for instance : if n == 0.777 , it will print out "0.777" in stead of "0.777000" if n == 0.777001 , it will print out exactly 6 digits after the decimal point ( "0.777001" ) */ Edited by author 25.07.2006 15:55 what if i want zero digits? using c++, not c Edited by author 28.08.2010 00:39 cout.precision( 6 ); cout << fixed << variable; You just need to check all possible numbers of L (1..10000) to solve this. So you get O(n^2) solution. You just need to check all possible numbers of L (1..10000) to solve this. So you get O(n^2) solution. Maybe O( n^3/2 )? Standard template library is not available or what? i am getting compilation error for this problem.This is my code <code> #include<iostream> #include<algorithm> using namespace std; class node{ public: int id,prob; bool operator<(const node &n)const{ return (prob>n.prob); } }; int main() { int n; scanf("%d",&n); node arr[n]; for(int i=0;i<n;i++){ scanf("%d%d",&arr[i].id,&arr[i].prob); } sort(arr,arr+n); for(int i=0;i<n;i++) { printf("%d %d\n",arr[i].id,arr[i].prob); } return 0; } </code> Edited by author 11.06.2008 17:19 just replace sort funcion to stable_sort Standard template library is not available or what? i am getting compilation error for this problem.This is my code <code> #include<iostream> #include<algorithm> using namespace std; class node{ public: int id,prob; bool operator<(const node &n)const{ return (prob>n.prob); } }; int main() { int n; scanf("%d",&n); node arr[n]; for(int i=0;i<n;i++){ scanf("%d%d",&arr[i].id,&arr[i].prob); } sort(arr,arr+n); for(int i=0;i<n;i++) { printf("%d %d\n",arr[i].id,arr[i].prob); } return 0; } </code> Edited by author 11.06.2008 17:19 1) node arr[n]; << ?? node arr[150000]; 2) If you put node arr[150000]; in main - you'll get stack overflow. Make so: node arr[150000]; int main() { int n; scanf("%d",&n); ... 3) Use stabe_sort instead of sort, or you catch WA#4. After that you'll get AC. http://acm.timus.ru/status.aspx?space=1&count=1&from=3148125 Good luck! Tell me please! Is it greedy??? Greedy only? I think. I don't solve else but think that next algo is right: 1. maximal production =d in all n periods; 2. Greedy approach :satisfy first demand as fully as possible; 3. If we have residue in last period equal to k diminish by k residues in previous periods until it is possible 4. Sum final residues along all periods. Edited by author 26.10.2008 20:52 My algo is the same as your! (but still wa 15) :-( You definitely need reading math eco theory optimal store managing(Taha a.s.o.) P.S.I also have WA14. First number of output I guarantee but the second need more delicate algo. may be your problem with the type of the second number(it should be __int64)??? Maxim Dvoynishnikov (Dnipropetrovsk SU) * [1] // Problem 1648. Yachts 27 Oct 2008 01:32 I have WA49 with greedy and restroring. use int64(long long) ,then you'll get AC. Yuare right! With __int 64 AC. I didn'r recognized masked danger:100000*100000=10*1-e9. All data seemed fitted in int type. Edited by author 27.10.2008 09:21 Are you got AC with your algo or you had chaged it??? Edited by author 28.10.2008 14:51 I considered stored values backward more attentievely according with alg: store[i-1]=max(store[i]+sell[i-1]-d,0) store[n]:=0; i=n..1 where sell[i-1] array of greedy selling on the first stage. Accepted!!!!!! this test help me find my bug... in: 5 5 3 1 20 3 10 out: 25 10 and now,after accepted, could somebody, who solved this problem with DP, sent to me your solution? my mail: asyamov@mail.ru Edited by author 28.10.2008 16:18 I think greedy can work well. I don'n understand, how to solve this problem whith DP or greedy. I solve with RMQ. Can anybody give me some good test? I can't find any bug Admins,i think i need you help As I can see you got ac. Could you tell me a hint for 25 test please? I'm sure I got WA because of reading string. Please help me, thanks. Here is my code to read string : ... fscanf(stdin,"%d\n",&m) ; for(int i=0;i<m;i++) { char s[1000] ; int j = 0 , k = 0 ; fscanf(stdin,"%s",&s) ; while ( s[j] != ',' ) a[i].x = a[i].x * 10 + s[j++] - 48 ; j++ ; while ( s[j] != ':' ) a[i].y = a[i].y * 10 + s[j++] - 48 ; j++ ; while (j < strlen(s) ) { while ( s[j] != '-' ) b[i][k] = b[i][k] * 10 + s[j++] - 48 ; j++ ; while ( j < strlen(s) && s[j] != ',' ) c[i][k] = c[i][k] * 10 + s[j++] - 48 ; k++ ; if ( s[j] == '\n' ) { j++ ; break ; } j++ ; } deg[i] = k ; } scanf("%d\n",&n); int i; int id,x,y,r; for (i = 0 ; i<n ; i++){ scanf("%d,%d:",&x,&y); while (true){ scanf("%d-%d",&id,&r); a[id][cnt[id]].x = x; a[id][cnt[id]].y = y; a[id][cnt[id]].r = r; cnt[id]++; char ch; ch = getc(stdin); if (ch!=',') break; }
} or: for (int i=0; i<m; i++){ char buf; cin >> tmp.x >> buf >> tmp.y; while ((buf=cin.get())!='\n' && buf!=EOF){ int id; cin >> id >> buf >>tmp.r; a[id].push_back(tmp); } } Simple problem, I use brute force, size of my code less 50 lines. The obvious solution is too simple. You should ask for the smallest numbers. That solution is also easy enough, so it shouldn't be a problem for most people. Anyway, maybe the purpose of this problem is to teach people to use __int64. In that case simpler is better :) Edited by author 22.02.2009 21:50 OMFG. :D At first I solved it with about 50 strings of code. But after AC I catcha the 5-strings solution. :D [code deleted] Edited by author 20.10.2006 23:12 Edited by moderator 01.12.2019 21:13 Algo is O(2n) The same algo on Pascal got AC in 0.156 sec Thank you Alexander, my algorithm AC 0.484 Can anybody give me some correct input-output data for testing? 1999 2002 123333 124421 321121 321123 11111111 11111111 0 0 I solve this problem about half of year. I use Binary Heap to store n/2+2 elemets at first. If you have WA 6-8 try to check your Binary Heap in some random tests with odd and even N (10 or 11) My wrong Binary Heap work different in other order of elements :) For example 10 1 2 3 4 5 6 7 8 9 10 10 10 9 8 7 6 5 4 3 2 1 10 1 6 8 3 9 5 2 10 4 7 Answers are 5.5 11 1 2 3 4 5 6 7 8 9 10 11 11 11 10 9 8 7 6 5 4 3 2 1 11 11 10 3 8 9 7 6 2 1 5 4 Answers are 6.0 P.S: Escape integer overflow :) Edited by author 09.10.2009 02:56 Data structure you used is called "binary heap", not "pyramide" =) Thank you! I got AC:) Very very usefull hint! Yep, another hint: Make array int a[250 000/4*3 + 2] Get numbers from 1 to min ( n, 250 000/4*3 + 2 ) Sort ( a, a + 250 000/4*3 + 2 ) Get the rest numbers from 250 000/4*3 + 2 + 1 to n in positions 125001 (counting from 0) .. till the end. Make sure they will fit. :) It's so because we have to read at most 250 000 / 4 numbers. :) Then sort again. That's the first 125001 numbers of your array. Output the answer. 125 ms 868 KB http://acm.timus.ru/status.aspx?space=1&num=1306&from=3146166&count=1 Edited by author 26.08.2010 15:25I passed for G (N ^ 2). Is this normal? What is the asymptotic behavior of a normal solution? Make program, which will find solution for test ><<<<<<<<...(29999 symbols '<'), and send it on timus. If it fails with WA1, then it's normal. If it fails with TL1, then it's weak testing. Sorry for bad english. Power of timus server not equal power of contest server. TL on thimus is not indicator. If you got TL then tests on this task should be harder and such solutions must fail. Better try test >>>...(15000 times)..>>><<<...(15000 times)..<<< If your solution passes it in time - then limitations of the problem are already too weak for modern computation facilities =( If it gets TL - then timus tests are just weak. Anyway, there exists correct O(N) algo... Where I can read about algorithm or idea? That's the main idea of the problem - not to read about an algorithm or idea but to turn your brains on and create it. This is possible (and even not difficult), try it! Anybody, can tell me what the test 9? when I got WA 9, my solution doesn't work on test: 8 0 2 4 6 8 9 10 11 |
|