| Show all threads Hide all threads Show all messages Hide all messages |
| s.o. to test this ?? | Black^n^White | 1150. Page Numbers | 5 Oct 2006 23:18 | 2 |
I can't see a problem in this soluton, but I get WA on test#3 I compared it with a lot of tests to a solution, that is surely correct - the results were always equal. #include <cstdlib> #include <cstdio> #include <cctype> int func(long pages,int dgts); char temp[10]; int main() { long pages; long dgts = 0; scanf("%i",&pages); char strpages[10]; sprintf(strpages,"%i",pages);
long j = 0;
while(isdigit(strpages[j])) { dgts++; ++j; }
if(pages > 100) { func(pages,dgts-1); system("pause"); return 0; }
int digits[] = {0,0,0,0,0,0,0,0,0,0}; for(long i = 1; i <= pages; ++i) { j = 0; sprintf(temp,"%i",i); while(isdigit(temp[j])) digits[temp[j++]-48]++; } for(long i = 0; i < 10; ++i) printf("%i\n",digits[i]);
system("pause"); return 0; } int func(long pages,int dgts) { long j = 0; long long_o, long_t; char* one = new char[dgts]; char* two = new char[dgts+1];
one[0] = dgts + 46; for(long k = 1; k < dgts-1; ++k) one[k] = '8';
one[dgts - 1] = '9'; long_o = atoi(one); two[0] = dgts + 48; for(long k = 1; k < dgts; ++k) two[k] = '0';
long_t = atoi(two);
long digits[10]; digits[0] = long_o; for(long i = 1; i < 10; ++i) digits[i] = long_t;
long start = 100; for(long i = 0; i < dgts - 2; ++i) start *= 10;
for(long i = start; i <= pages; ++i) { j = 0; sprintf(temp,"%i",i); while(isdigit(temp[j])) digits[temp[j++]-48]++; } for(long i = 0; i < 10; ++i) printf("%i\n",digits[i]); return 0; } Edited by author 05.10.2006 23:19 Edited by author 05.10.2006 23:19 |
| AC in 0.046 =) | ronobe (aka oberon) | 1333. Genie Bomber 2 | 5 Oct 2006 21:20 | 4 |
Me too =) ronobe (aka oberon) 7 Mar 2005 15:42 779321 15:38:34 7 мар 2005 ronobe (aka oberon) 1333 C++ Accepted 0.015 107 КБ The time and exectness can be changed by one constant. In first AC submission it was 100000. In three next submissions this constant was lowered to 10000, 1000, 100 and I got AC too in 0.015... that's boring. AC - is most wanted. Not in this problem... Edited by author 05.10.2006 21:29 Edited by author 05.10.2006 21:29 |
| Почему нет сэмпла??? | Sergeyev Alexander | 1333. Genie Bomber 2 | 5 Oct 2006 21:16 | 2 |
С какой точностью выводить? One persent as written ;D |
| One question | Samsonov Alex [USU] | 1181. Cutting a Painted Polygon | 5 Oct 2006 19:06 | 3 |
Is that true that we should output "0" if: 1) There are less than three colors in the polygon. 2) Vertex of one color is followed by the vertex of the same color (like "GG")? There is no "0" at all! Because all these situation are discribed in the task!)) |
| I got TL#10 and I don't know what to do because on my computer it works only 0.352 sec on max test! PROGRAMMERS please help me!!! | Andriy Buday [Lviv NU] | 1291. Gear-wheels | 5 Oct 2006 13:56 | 3 |
My algorithm is: At first I make some class (for example wheel) which is like rational numbers (with numerator and denumerator) then I read input data in static arrays, after that I (recursivly) do initialisation of array of wheels starting from wheel, that is connected to the kinetic-generator, in the end I output all initialised wheels. // My CODE: Sorry but I know only C++ //1291_TL10 //I had deleted my code :) Edited by author 03.02.2007 23:52 Edited by author 03.02.2007 23:52 I'm not very familiar with C++, so I can't understand your code normally, but I can try to help you anyway. I solved it using BFS, but I think if you recurse only on wheels you haven't visited yet, it shouldn't cost much more time. The second thing is how you compute the reduced fraction. I did it dividing the numerator and denominator by their GCD until it was 1 just as I reached the wheel. If you are doing exactly the same, then try solving this problem using BFS... Thank you. Now I got AC. My problem was in computing reduced fraction. So I got AC with time 0.001 and without BFS!! One more thank you.
|
| Why I have t=0.7691 on example test? | Kirin Vladislav | 1359. Construction | 4 Oct 2006 16:41 | 2 |
I have calculate time by formula t=sqrt(2*s/g) there s - distance and g - changing speed (g=10m/c^2). Distance I have calculate by trapezium method. I have distance for this test s=2.9578. There is wrong?:-( I find where I made mistake - in idea of solution: traectory of moving barrel is not a parabola, it's a cycloid. But I have next problem - what is formula of cycloid? Edited by author 04.10.2006 16:43 Edited by author 04.10.2006 16:45 |
| Why WA on Test#2 ???? | MultiThread | 1126. Magnetic Storms | 4 Oct 2006 13:01 | 1 |
I don't know why WA. :-( Could you kindly give me the test#2? Thanks a lot. |
| My eye is still twitches! I got WA #5! code here | Alias aka Alexander Prudaev | 1236. Decoding Task | 4 Oct 2006 09:58 | 3 |
how it is possible? program work on 1-st,2nd, 3th and 4th tests, but on test #5 it gives WA?! plase help me! my program: [code deleted by autor.] Edited by author 04.10.2006 09:59 Try this 32 0AC9 Your answer: 0A and two spaces Right answer: 0AC9 And this AA AAAA Your answer has only spaces, and the real answer is 8A8A!) Good Luck! Edited by author 03.10.2006 20:49 Try this 32 0AC9 Your answer: 0A and two spaces Right answer: 0AC9 Right answer: 2AD1. However, thank you. I found my mistake. t must be unsigned char. There is Access violation if t - char. |
| What functions of "C++" work slower than that of C? | begi | | 3 Oct 2006 23:30 | 2 |
I just sent two solutions to proble 1048,one in C++ and the other in C. The algorithm was the same but C++ got "time limit exceeded" but C got AC.Look below: C++ program: #include<iostream> using namespace std; int main() { int *A,*B,*R,n,carry = 0; cin >> n; A = new int[n]; B = new int[n]; R = new int[n]; for(int i=0;i<n;i++) cin >> A[i] >> B[i]; for(int i=0;i<n;i++) { int tmp = A[n-i-1]+B[n-i-1]; R[i] = (tmp+carry)%10; carry = (tmp+carry)/10; } if(carry) cout << carry; for(int i=0;i<n;i++) cout << R[n-i-1]; cout << endl; return 0; } C program: #include<stdio.h> #include<stdlib.h> int main() { int *A,*B,*R,i,n,tmp,carry = 0; scanf("%d",&n); A = (int *)malloc(n*sizeof(int)); B = (int *)malloc(n*sizeof(int)); R = (int *)malloc(n*sizeof(int)); for(i=0;i<n;i++) scanf("%d %d",&A[i],&B[i]); for(i=0;i<n;i++) { tmp = A[n-i-1]+B[n-i-1]; R[i] = (tmp+carry)%10; carry = (tmp+carry)/10; } if(carry) printf("%d",carry); for(i=0;i<n;i++) printf("%d", R[n-i-1]); printf("\n"); return 0; } |
| Hello everyboby! I found solution in O(n^4), what about others? (-) | Victor Barinov (TNU) | 1359. Construction | 3 Oct 2006 21:16 | 6 |
The fastest solution is precalc (as usual :] ), but you can make your solution very fast without it. It is clear that there is some physical dependence in this problem - the line of optimal movement is some function (a parabola, I presume). So you can look for several nearest points with integer coordinates and use dp only for them. But it is much more difficult and unsafe, isn't it? Not parabola, but cycloid! It's variational stuff :)! What is cycloid's formula? |
| why WA on test1? | John | 1005. Stone Pile | 3 Oct 2006 18:28 | 1 |
var f:array[0..1100000] of boolean; e,i,n,temp,w,min,q,ans,j,temp1,k:longint; a:integer; begin fillchar(f,sizeof(f),false); f[0]:=true; read(n); temp:=0;temp1:=0; for i:=1 to n do begin read(a); temp1:=temp1+a; for w:=temp downto 0 do if f[w] then f[w+a]:=true; if temp<1000000 then temp:=temp+a; end; min:=maxlongint; e:=temp1 div 2; for j:=0 to temp do if f[j] then begin q:=abs(j-e); if q<min then begin k:=temp1-j; min:=abs(k-j); end; end; writeln(min); end. |
| Time Limit Exceeded | Nataraj | 1322. Spy | 2 Oct 2006 23:31 | 2 |
I get "Time Limit Exceeded" error on 9 test. Time: 0.281, Size: 424KB I implemented Burrows - Wheeler algorithm in C++ in quite straight forward way (even without sorting). What could be the problem and how it is possible to make it faster? I found the problem. It was using 'string' class instead of just char array. Probably when a string is long (100000 characters) then C++ allocate its memory in chucnks which make its access much more slower (or maybe because some limit checks). Anyway, when I changes it to char array, it's running time was at least 10 time faster!!! |
| WA 14 | Alias aka Alexander Prudaev | 1329. Galactic History | 2 Oct 2006 21:50 | 1 |
WA 14 Alias aka Alexander Prudaev 2 Oct 2006 21:50 please help, give me some exemples if descendant(A,B)==true, if A is descendant for B int level(int X) == level of vertex with number X, level(root)==0 my code: ... for (i=0;i<L;i++) { int a,b; scanf("%i %i",&a,&b); if (a==b){printf("0\n");continue;} if (level(a)<level(b)) { if (descendant(b,a)) printf("1\n"); else printf("0\n"); } else { if (descendant(a,b)) printf("2\n"); else printf("0\n"); } } WHY I got WA14? please help me |
| Please, give me idea, how to solve it! | EFREMOV[USU] | 1449. Credit Operations 2 | 2 Oct 2006 21:14 | 1 |
|
| Last string of input contains INTEGER VALUE ???? | The Punisher | 1291. Gear-wheels | 2 Oct 2006 19:44 | 2 |
Last string of input contains INTEGER VALUE ???? Help me please. Yes, at least my AC program read it as an integer :) |
| WA9,help please. | strike freedom | 1472. Martian Army | 2 Oct 2006 12:41 | 1 |
|
| WA 1 ! ! ! | Barnaul S42#4:Kolesnikov, Votjakov, Zarechnev | 1306. Sequence Median | 2 Oct 2006 11:07 | 3 |
WA 1 ! ! ! Barnaul S42#4:Kolesnikov, Votjakov, Zarechnev 28 Sep 2006 14:20 Program works on all my tests, but WA 1 ! ! ! Where is problem, if I use Heap? On such test 1 1 You should output 1.0! Good Luck! (Heap rulez! :)) ThanX! We find where is wrong! |
| Whether he can change figures in 2 different numbers simultaneously | Kurpilyansky Eugene (USU) | 1435. Financial Error | 1 Oct 2006 22:41 | 1 |
Edited by author 01.10.2006 22:41 |
| Why WA on TEST#1 SOS SOS~~~~~~~~ | MultiThread | 1029. Ministry | 1 Oct 2006 09:10 | 1 |
I don't know why it WAs on #1. I think my algorithm should work. The following is my code. Thinks in advance. #include <stdio.h> #include <stdlib.h> #include <math.h> void main() { const int MAXN = 501; const int MAXM = 101; long double F[MAXM][MAXN] = {0}; unsigned long cost[MAXM][MAXN] = {0}; unsigned long s[MAXM][MAXN] = {0}; bool mark[MAXM][MAXN] = {false}; //FILE * fin = fopen ("E:/Algorithm/Timus/data.txt", "r"); FILE * fin = stdin; int M = 0; int N = 0; fscanf (fin, "%d%d", &M, &N); int i = 0; int j = 0; for (i = 1; i <= M; i++) { for (j = 1; j <= N; j++) { fscanf (fin, "%d", &cost[i][j]); } } for (j = 1; j <= N; j++) { F[M][j] = cost[M][j]; } unsigned long result = 1e11; for (i = M - 1; i >= 1; i--) { int minIndex = 0; long double min = 1e20; for (j = 1; j <= N; j++) { if (F[i+1][j] + cost[i][j] < min) { min = F[i+1][j] + cost[i][j]; minIndex = j; } } F[i][minIndex] = min; s[i][minIndex] = (i + 1) * 10 + minIndex; for (int j = 1; j <= N; j++) { if (mark[i][minIndex] == false) { mark[i][minIndex] = true; if (minIndex - 1 >= 1 && mark[i][minIndex-1] == false) { if (F[i+1][minIndex-1] + cost[i][minIndex-1] > F[i][minIndex] + cost[i][minIndex-1]) { F[i][minIndex-1] = F[i][minIndex] + cost[i][minIndex-1]; s[i][minIndex-1] = i * 10 + minIndex; } else { F[i][minIndex-1] = F[i+1][minIndex-1] + cost[i][minIndex-1]; s[i][minIndex-1] = (i + 1) * 10 + minIndex - 1; } } if (minIndex + 1 <= N && mark[i][minIndex+1] == false) { if (F[i+1][minIndex+1] + cost[i][minIndex+1] > F[i][minIndex] + cost[i][minIndex+1]) { F[i][minIndex+1] = F[i][minIndex] + cost[i][minIndex+1]; s[i][minIndex+1] = i * 10 + minIndex; } else { F[i][minIndex+1] =F[i+1][minIndex+1] + cost[i][minIndex+1]; s[i][minIndex+1] = (i + 1) * 10 + minIndex + 1; } } long double tempMin = 1e20; int tempIndex = minIndex; if (minIndex - 1 >= 1 && mark[i][minIndex-1] == false && tempMin > F[i][minIndex-1]) { tempMin = F[i][minIndex-1]; tempIndex = minIndex - 1; }
if (minIndex + 1 <= N && mark[i][minIndex+1] == false && tempMin > F[i][minIndex+1]) { tempMin = F[i][minIndex+1]; tempIndex = minIndex + 1; } minIndex = tempIndex; } } } int index = 0; for (j = 1; j <= N; j++) { if (result > F[1][j]) { result = F[1][j]; index = j; } } int X = 1; int Y = index; while (X >= 1) { printf ("%d\n", Y); int t = s[X][Y]; X = t / 10; Y = t % 10; } } |
| Test 5 | Mike | 1073. Square Country | 1 Oct 2006 04:20 | 2 |
Author: Test 5 -- Wrong answer Correct -- 2: 2^2+1^2 Why Error Edited by author 23.09.2006 02:26 check test 181: correct answer is 2: 10^2+9^2. |