Common Board| Show all threads Hide all threads Show all messages Hide all messages | | TO ADMINS: Invalid Test #11 (-) | DixonD (Lviv NU) | 1373. Pictura ex Machina | 31 Dec 2007 02:28 | 4 | There are trailing spaces in some lines of input in test 11. Please, check this. Edited by author 25.12.2007 02:47 Please, give me answer, don't ignore my request...(( Now N <= 100000, Time Limit is 1 sec. All tests with trailing spaces are fixed. | | random algorithm | lian lian | 1510. Order | 30 Dec 2007 15:12 | 7 | this is my code: #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { long K[5000005],N,i,j,t,value,k,count,a,flag; scanf ("%ld",&N); if (N%2==0) k=N/2; else k=N/2+1; for (i=0;i<N;i++) scanf("%ld",&K[i]); for(i=0;i<N;i++){ j=rand()%N; for(flag=0,count=1,t=0;t<N;t++){ if (K[t]==K[j]) count++; if (count>=k){ value=K[j]; flag=1; break; } } if (flag=1) break; } printf("%ld\n",value); return 0; } why Crash (stack overflow)? please help me ? define big arrays outside procedures long K[5000005] I modify small than long K[5000005] to k[500005],but it Crash (stack overflow)? change you prog to -------------- long K[5000005] int main() { long N,i,j,t,value,k,count,a,flag; scanf ("%ld",&N); ------------ or use #pragma comment(linker, "/STACK:16777216") defaut stack size ~1mb Edited by author 29.12.2007 01:18 Thanks ( KIRILL(ArcSTUpid coder:) )to solve problem of memory for me,but now answer is wrong; could you mail to me for 1510?
email: k13795263@126.com thanks; The problem in rand(); See documentation for return value. It's too small. You need something like this: t = (rand()*rand())%N; | | DP | svr | 1267. Yekaterinburg Subway | 30 Dec 2007 10:22 | 1 | Excellent problem. Very realistic and DP works. Small advice: We should consider moments after stationary condition established: first trains went to last stations. Without this we must include 10^5 moments in Dp and will be MLE and TLE. Edited by author 30.12.2007 10:32 | | What answer for n=2? | Ikari [pskov] - Andrey Marchenko | 1222. Chernobyl’ Eagles | 28 Dec 2007 22:31 | 3 | I think that correct answer for n=2 is 1, because if one of eagles has 2 heads and another 0 heads then IQ will be 2*0=0, isn't it? But my program had WA3 in that case. When I wrote 2 in output for n=2, I got accepted. Why? because you can have only ONE eagle with 2 heads in group, so IQ = 2. There was no obligations that group should consist of >=2 eagles... Edited by author 28.12.2007 21:55 Edited by author 28.12.2007 21:55 | | I've got AC.Just try this testdata | lonelycorn | 1244. Gentlemen | 28 Dec 2007 20:13 | 1 | 270 5 50 50 100 110 170 and the answer is -1 | | could any C/C++ programmer solve this question?? | manishmmulani | 1017. Staircases | 28 Dec 2007 17:48 | 3 | because... even the data type "long long" works only for numbers till 490 ... from 491 to 500... it gives wrong answer can any1 help please??
your solution is wrong besause answer always is less than 10^18 thanx a lot... i got my mistake | | Sorting is the most sophisticated thing I've used to solve the problem (-) | Vedernikoff Sergey | 1499. Kerchiefs | 28 Dec 2007 03:35 | 1 | | | why i got wrong 4? | shengxi4 | 1120. Sum of Sequential Numbers | 27 Dec 2007 22:10 | 4 | #include<stdio.h> long n,a,k; void work () { long i,na,x; if (n<316227) x=2*n; else x=316227; for (i=x;i>=1;i--) { na=2*n+i-i*i; if (((na%(2*i))==0)&&(na>0)) { na=na/(2*i); a=na; k=i; break; } } } int main () { scanf ("%ld",&n); work (); printf ("%ld %ld",a,k); return 0; } Test: 10^9 Your program result: 4811 148480 My AC program result: 26263 25600 My program result: 1243 640 for n= 10^6 Edited by author 27.12.2007 22:11 #include<iostream> #include<stdio.h> using namespace std; __int64 n,a,k; void work () { __int64 i,na,x; if (n<316227) x=2*n; else x=316227; for (i=x;i>=1;i--) { na=2*n+i-i*i; if (((na%(2*i))==0)&&(na>0)) { na=na/(2*i); a=na; k=i; break; } } } int main () { cin>>n; work (); cout<<a<<" "<<k; return 0; } #include<stdio.h> long n,a,k; void work () { long i,na,x; if (n<316227) x=2*n; else x=316227; for (i=x;i>=1;i--) { na=2*n+i-i*i; if (((na%(2*i))==0)&&(na>0)) { na=na/(2*i); a=na; k=i; break; } } } int main () { scanf ("%ld",&n); work (); printf ("%ld %ld",a,k); return 0; } | | WA on #14. | lonelycorn | 1039. Anniversary Party | 27 Dec 2007 20:31 | 1 | i've been making it for nearly a week and i still get WA on #14.who can tell me why,or give me the data? | | Why I got wa on test#4? | panrui | 1588. Jamaica | 27 Dec 2007 20:20 | 1 | #include<iostream> #include<math.h> #define MAX 200000 #define N 350 using namespace std; int n; double map1[N][N]; struct node { int x,y; }point[N]; double dist(node a,node b) { return sqrt((double)((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y))); } void init() { cin>>n; int i,j; for(i=1;i<=n;i++) cin>>point[i].x>>point[i].y; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { map1[i][j]=dist(point[i],point[j]); //cout<<map1[i][j]<<" "; } //cout<<endl; } } double calck(node a,node b) { if(a.x-b.x!=0) return (a.y-b.y)/(a.x-b.x);else return -MAX; } int mid(node c,node a,node b) { if(a.x!=b.x) { if(abs(a.x-b.x)>abs(a.x-c.x)) return 1; }else if(abs(a.y-b.y)>abs(a.y-c.y)) return 1; return 0; } void solve() { int i,j,k,used[N][N]; double ans=0; for(i=1;i<=n;i++) for(j=1;j<=n;j++) { ans+=map1[i][j]; used[i][j]=0; } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { for(k=1;k<=n;k++) { if(i==j || j==k || i==k) continue; if(calck(point[i],point[j])==calck(point[i],point[k]) && mid(point[k],point[i],point[j]) && used[i][k]==0 && used[k][i]==0) {ans-=map1[i][k]*2;used[i][k]=1;} } } } ans/=2; cout<<(int)(ans)<<endl; } int main() { init(); solve(); return 0; } | | No subject | Я крыса которая съест тебя! | 1228. Array | 27 Dec 2007 01:01 | 3 | No subject Я крыса которая съест тебя! 16 Dec 2007 03:02 Edited by author 12.01.2008 04:09 Edited by author 12.01.2008 04:10 Edited by author 12.01.2008 04:10 | | I got wa#12... help me please... | Crash_access_violation | 1400. Cellular Characters | 26 Dec 2007 23:50 | 1 | please give me some right tests... thanks... | | it is too strange | lian lian | 1098. Questions | 26 Dec 2007 22:50 | 1 | Could anybody tell me how should I read the input in "c"? | | WA on #8? | lonelycorn | 1114. Boxes | 26 Dec 2007 19:52 | 1 | use unsigned long or qword to get ac | | Pls some1 tell me what 's the TEST#1 | manishmmulani | 1112. Cover | 26 Dec 2007 16:48 | 1 | pls someone help me... i'm getting WA1 | | Pls some1 tell me what 's the TEST#1 | manishmmulani | 1152. False Mirrors | 26 Dec 2007 16:46 | 1 | my brute force program... works for all cases ... still getting WA 1.. #include<stdio.h> long min = 1000000000; void recur(int arr[] , int n , int finished[] , int finishedCount , int total , long damage) { int i , k , l , sum , tempfinishedCount , flag , a, b , c; if( finishedCount == n ) { if( damage < min ) min = damage; return ; } if( damage > min ) return ; for( i = 0 ; i < n ; i++ ) { k=(i+1)%n; l=(k+1)%n; sum=0; tempfinishedCount=finishedCount; flag = 0; if( !(a=finished[i]) ){ finished[i] = 1; finishedCount++; sum+=arr[i]; flag=1; } if( !(b=finished[k]) ){ finished[k] = 1; finishedCount++; sum+=arr[k]; flag=1; } if( !(c=finished[l]) ){ finished[l] = 1; finishedCount++; sum+=arr[l]; flag=1; } if(!flag) continue; total -= sum; damage+= total; recur( arr , n , finished , finishedCount ,total , damage ); damage-=total; total += sum; finished[i]=a; finished[k]=b; finished[l]=c; finishedCount=tempfinishedCount; } } int main() { int n , i ,arr[21] , finished[21]={0} , finishedCount = 0 , total; scanf("%d",&n); for( i = 0 ; i < n ; i++ ) { scanf("%d",&arr[i]); total+=arr[i]; } if( n <=3 ) printf("0\n"); else { recur( arr , n , finished , finishedCount , total , 0 ); printf("%ld\n",min); }
return 0; } | | problem 1129 | tyana | | 25 Dec 2007 16:11 | 1 | Whether in a problem 1129 some variants of the answer are possible?? | | can anybody tell me how to read the inputs? | Anupam Ghosh,Bengal Engg and Science University,Shibpur,India | 1005. Stone Pile | 24 Dec 2007 15:39 | 2 | one in each line or all in single line.?? for C it is don't matter int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); Edited by author 24.12.2007 15:39 | | Can someone check my answer? thanks | semiconductor | 1368. Goat in the Garden 3 | 24 Dec 2007 15:07 | 6 | Is it right? K minimum fence 10 13 11 13 12 14 13 15 14 15 15 15 16 16 17 17 18 17 19 17 20 18 21 19 22 19 23 19 24 19 25 20 26 21 27 21 28 21 29 21 30 22 31 23 32 23 33 23 34 23 35 23 36 24 37 25 38 25 39 25 40 25 41 25 42 26 43 27 44 27 45 27 46 27 47 27 48 27 49 28 50 29 No. For example: 10 11 13 12. Good luck! Can u tell me how to put the fence? when k=10,the answer=11. N = 10 -> 11 fences (_ space, * fence, 0 goat square) ___*__ __*0*_ _*000* *0000* _*00*_ __**__ Edited by author 04.05.2005 19:59 Edited by author 04.05.2005 20:00 Make someone verification,please, for: 1 4 2 6 3 7 4 8 5 8 6 9 7 10 8 10 9 11 10 11 11 12 12 12 13 12 14 13 15 13 16 14 17 14 18 14 19 15 20 15 21 15 22 16 23 16 24 16 25 16 26 17 27 17 28 17 29 18 30 18 31 18 32 18 33 19 34 19 35 19 36 19 37 20 38 20 39 20 40 20 41 20 42 21 43 21 44 21 45 21 46 22 47 22 48 22 49 22 50 22 51 23 52 23 53 23 54 23 55 23 56 24 57 24 58 24 59 24 60 24 61 24 62 25 63 25 64 25 65 25 66 25 67 26 68 26 69 26 70 26 71 26 72 26 73 27 74 27 75 27 76 27 77 27 78 27 79 28 80 28 81 28 82 28 83 28 84 28 85 28 86 29 87 29 88 29 89 29 90 29 91 29 92 30 93 30 94 30 95 30 96 30 97 30 98 30 99 31 100 31 Edited by author 24.12.2007 14:30 Here my testing program which makes full search for K<=100 and use DP. z[i][j]- minimal value when i=K and 1<=j<=i-size of last row; z[i]=min(z[i][j]),j=1,...,i I have WA8 for which K<=100 with my real quick prog but in range [1,100] results are coinsise. int zz[100][100],z[100]; void help() { int i,k,j,h; zz[0][0]=0; for (i=1;i<=100;i++) { z[i-1]=10000; for (j=1;j<=i;j++) { if (j==i) zz[i-1][j-1]=2*j+2; else { zz[i-1][j-1]=10000; for (k=1;k<=i-j;k++) { h=zz[i-j-1][k-1]; if (j<=k-2) zz[i-1][j-1]=min(zz[i-1][j-1],h); else if (j<=k-1) zz[i-1][j-1]=min(zz[i-1][j-1],h+1); else if (j==k)zz[i-1][j-1]=min(zz[i-1][j-1],h+2); else if (j==k+1)zz[i-1][j-1]=min(zz[i-1][j-1],h+3); else zz[i-1][j-1]=min(zz[i-1][j-1],h-k+j+2+j-k-2);
} } z[i-1]=min(z[i-1],zz[i-1][j-1]); } } } | | What is the 5-th test? | realman.lv(Lviv NU) | 1414. Astronomical Database | 24 Dec 2007 01:44 | 2 | |
|
|