Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Time limit exceeded | david | 1209. 1, 10, 100, 1000... | 11 Feb 2013 02:49 | 2 | What's wrong? var n,p,k,i:longint; m:array [1..65535] of longint; begin readln(n); p:=1; k:=0; for i:=1 to n do readln(m[i]); for i:=1 to n do begin while m[i]>p do begin p:=p+k; k:=k+1; end; if p=m[i] then write(1,' ') else write(0,' '); p:=1; k:=0; end; end. you shold use maths method, maths formula | | Who can help me with WA#3 ? | Iosif inf-10 | 1220. Stacks | 10 Feb 2013 18:10 | 1 | #include <stdio.h> #define MaxN 100000+252 #define MaxPop MaxN/2+1 struct pointer { int s; char o; }; struct pointer GetPointer(int i) { struct pointer p; p.s=i/250; p.o=i % 250; return p;
} struct Stack { int V; struct pointer pred; }; int GetAdress(struct pointer p) { return p.s*250+p.o; } int A[1001]; int MP; struct Stack B[MaxN]; int Pop(int S) { int E; E=B[A[S]].V; A[S]=GetAdress(B[A[S]].pred); return E; } int Push(int S, int E) { int i=A[S]; MP++; B[MP].V=E; B[MP].pred=GetPointer(i); A[S]=MP; return 0; } int main() {
int N,i,j,E,k; int S; char command[10]; scanf("%d",&N);
MP=0; B[MP].V=0; B[MP].pred=GetPointer(0); for (i=1;i<1000;i++) A[i]=0; k=0; for (i=1;i<=N;i++) {
scanf("%s",command); if (command[1] == 'U'){ scanf("%d %d",&S,&E); Push(S,E); } else { scanf("%d",&S); k++; printf("%d\n",Pop(S)); } }
return 0; } | | 1220. Stacks Who can help me with WA#3 ? | Iosif inf-10 | | 10 Feb 2013 18:09 | 1 | Here is my code #include <stdio.h> #define MaxN 100000+252 #define MaxPop MaxN/2+1 struct pointer { int s; char o; }; struct pointer GetPointer(int i) { struct pointer p; p.s=i/250; p.o=i % 250; return p;
} struct Stack { int V; struct pointer pred; }; int GetAdress(struct pointer p) { return p.s*250+p.o; } int A[1001]; int MP; struct Stack B[MaxN]; int Pop(int S) { int E; E=B[A[S]].V; A[S]=GetAdress(B[A[S]].pred); return E; } int Push(int S, int E) { int i=A[S]; MP++; B[MP].V=E; B[MP].pred=GetPointer(i); A[S]=MP; return 0; } int main() {
int N,i,j,E,k; int S; char command[10]; scanf("%d",&N);
MP=0; B[MP].V=0; B[MP].pred=GetPointer(0); for (i=1;i<1000;i++) A[i]=0; k=0; for (i=1;i<=N;i++) {
scanf("%s",command); if (command[1] == 'U'){ scanf("%d %d",&S,&E); Push(S,E); } else { scanf("%d",&S); k++; printf("%d\n",Pop(S)); } }
return 0; } Edited by author 10.02.2013 18:10 | | WA6 | Shree | 1823. Ideal Gas | 10 Feb 2013 04:21 | 1 | WA6 Shree 10 Feb 2013 04:21 What is test 6? I am stuck at it for a very long time! | | Please help with DFS. | freelife | 1837. Isenbaev's Number | 10 Feb 2013 03:12 | 1 | What is the true way to change k-(needed numbers) http://pastebin.com/f27Pt0HC - code #include <iostream>; #include <map>; #include <string>; using namespace std; // dfs( копия матрицы, кол-во вершин, указатель на юзет, в который будут добавлятся числа Исенбаева, проверяемое ребро, число Исенбаева в данный момент) int dfs(int **gr, int n, int *&q, int v, int k) { for(int i=0;i<n;i++) if ( (gr[v][i]==-1)&&(q[i]==1000) )//если из v в i есть путь и если i не обойдена { q[i]=min(k,q[i]);//чтобы избавится от 1000 dfs(gr,n,q,i,k+1); } return 1; } int main() { int x,i,j,m,n; map<string,int> a; n=0; cin>>m; int **gr=new int*[3*m]; //матрица смежности for(int i=0;i<3*m;i++) gr[i]=new int[3*m]; string s1,s2,s3; for(int i=0; i<m; i++)//ввод фамилий по 3 в строке { cin>>s1>>s2>>s3; if (a[s1]==0) a[s1]=++n; if (a[s2]==0) a[s2]=++n; if (a[s3]==0) a[s3]=++n; gr[ a[s1] ] [ a[s2] ] =-1; gr[ a[s2] ] [ a[s1] ] =-1; gr[ a[s3] ] [ a[s1] ] =-1; gr[ a[s1] ] [ a[s3] ] =-1; gr[ a[s3] ] [ a[s2] ] =-1; gr[ a[s2] ] [ a[s3] ] =-1; }; int k=1; x=a["Isenbaev"]; int *used=new int[n]; for(int i=0;i<n;used[i++]=1000); int *&q=used; cout<<dfs(gr,n,used,x,1); i=0; used[x]=0; for(map<string,int>::const_iterator x=a.begin();x!=a.end();++x,i++) if(used[i]<1000) cout<<x->first<<' '<<used[i]<<endl; else cout<<x->first<<" undefined"<<endl; delete gr,used; return 0; } | | Help-WA Test6 | moonshang | 1002. Phone Numbers | 9 Feb 2013 23:40 | 3 | Could anyone give me the test#6? godsuriyel@gmail.com thanks! I print all answers before now AC,thanks ok [RSU_Tash]Nodirbek_Kuklamov 9 Feb 2013 23:40 ok Edited by author 09.02.2013 23:40 | | Template for a testing. C++ | Oleksandr Ushkalenko | 1355. Bald Spot Revisited | 9 Feb 2013 22:14 | 1 | /* * You should only define the SURC_TEST macros * in the compile directives! */ #include <stdio.h> void main(void) { int nT, a, b, nResult; #ifndef SURC_TEST scanf ("%d", &nT); #else nT = 27; #endif for (int iT = 0; iT < nT; ++iT) { #ifndef SURC_TEST scanf ("%d %d", &a, &b); #else switch (iT) { case 0: a = 30; b = 89; break; case 1: a = 2; b = 16; break; case 2: a = 3; b = 243; break; case 3: a = 1; b = 1; break; case 4: a = 2; b = 2; break; case 5: a = 2; b = 72; break; case 6: a = 1; b = 536870912; break; case 7: a = 1; b = 536870912; break; case 8: a = 1; b = 214358881; break; case 9: a = 1; b = 147008443; break; case 10: a = 1; b = 352275361; break; case 11: a = 1; b = 28934443; break; case 12: a = 1; b = 214921799; break; case 13: a = 1; b = 1042441; break; case 14: a = 1; b = 2627641; break; case 15: a = 1; b = 6086089; break; case 16: a = 1; b = 12823561; break; case 17: a = 1; b = 24730729; break; case 18: a = 1; b = 44930209; break; case 19: a = 1; b = 77810041; break; case 20: a = 1; b = 129254161; break; case 21: a = 1; b = 207561649; break; case 22: a = 1; b = 319730161; break; case 23: a = 1; b = 480091921; break; case 24: a = 1; b = 707081281; break; case 25: a = 1; b = 31973; break; case 26: a = 1; b = 499999999; break; default: a = 1; b = 1; break; } #endif nResult = 0; /********** ALGORITM START ******** * Insert your algorithm here. * input: a, b * result write to: nResult */ // ********* ALGIROTM END ********* #ifndef SURC_TEST printf ("%d\n", nResult); #else int nRightResult; switch (iT) { case 0: nRightResult = 0; break; case 1: nRightResult = 4; break; case 2: nRightResult = 5; break; case 3: case 4: nRightResult = 1; break; case 5: nRightResult = 5; break; case 6: case 7: nRightResult = 30; break; case 8: nRightResult = 9; break; case 9: nRightResult = 6; break; case 10: nRightResult = 5; break; case 11: case 12: nRightResult = 4; break; case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: nRightResult = 3; break; case 25: nRightResult = 2; break; case 26: nRightResult = 3; break; default: nRightResult = 1; break; } if (nResult == nRightResult) printf ("%d\tT\n", iT); else printf ("%d\tF: %d (should be: %d)\n", iT, nResult, nRightResult); #endif } } Edited by author 09.02.2013 22:15 Edited by author 09.02.2013 22:15 | | Wrong answer .13 test | Probaa | 1133. Fibonacci Sequence | 9 Feb 2013 19:50 | 2 | who know 13 test . Please help me
| | useful for wa#6 | Barsuk Alexey [Pskov] | 1709. Penguin-Avia | 9 Feb 2013 18:53 | 2 | If you use dfs, try this test 5 1 3 01000 10111 01000 01000 01000 Answer is: 0 00000 00000 00000 00000 00000 It is rather useful. Thanks. | | Pretty shit task | Andrew Sboev | 1506. Columns of Numbers | 9 Feb 2013 11:45 | 3 | Some tests 7 2 1 2 3 4 5 6 7 Answer 1 5 2 6 3 7 4 7 6 1 2 3 4 5 6 7 Answer 1 3 4 5 6 7 2 This answer can't be right. Only the last column may be smaller. Here 5 columns are smaller. OK, second test is not correct, I think now. | | Please! Tell me anyone, What's tested in test 3? All my attempts stopped in third test!((( | kami_botanik | 1877. Bicycle Codes | 9 Feb 2013 02:21 | 1 | | | WA7 | pmartynov | 1244. Gentlemen | 9 Feb 2013 00:59 | 1 | WA7 pmartynov 9 Feb 2013 00:59 ALL tests from the discussion passed and still WA7. Any suggestions? | | Need help with prove | exwRabbits_AlMag(VNTU) | 1874. Football Goal | 8 Feb 2013 15:41 | 2 | The key for solution was realizing that the ends of the sticks was on the same distance from origin. How to prove that? I have a function F(angleA, angleB). I took derivatives dF/angleA and dF/angleB, they must be equal to zero. Then what? Refer to my new topic :) Cheers | | easy search | Artem Ladik | 1073. Square Country | 8 Feb 2013 11:25 | 6 | var i,j,k,n:longint; begin read(n); for i:=1 to 250 do if sqr(i)=n then begin write(1); exit; end; for i:=1 to 250 do for j:=1 to 250 do if sqr(i)+sqr(j)=n then begin write(2); exit; end; for i:=1 to 250 do for j:=1 to 250 do for k:=1 to 250 do if sqr(i)+sqr(j)+sqr(k)=n then begin write(3); exit; end; write(4); end. If N was bigger, you would have time limit. I don't think so. My code got AC. #include<stdio.h> int i,j,k; long int n; int main() { scanf("%d",&n);
for(i=1;(i*i)<=n;i++) if((i*i)==n) { printf("%d",1); return 0; } for(i=1;i*i<=n;i++) for(j=1;j*j<=n;j++) if((i*i+j*j)==n) { printf("%d",2); return 0; }
for(i=1;i*i<=n;i++) for(j=1;j*j<=n;j++) for(k=1;k*k<=n;k++) if((i*i+j*j+k*k)==n) { printf("%d",3);
return 0; }
printf("%d",4); return 0;
} But this solution is bad. I think it's DP in this problem O(n*sqrt(n)); for(i=1;(i*i)<=n;i++) if((i*i)==n) { printf("%d",1); return 0; } you can just write if (sqrt(n) * sqrt(n) == n) this is the most epic answer I've read....hhhh :) u are awesome thanks dud and good luck | | why why why wrong answer??? | esekkelle | 1157. Young Tiler | 8 Feb 2013 11:07 | 1 | # include <math.h> # include <stdio.h> # include <algorithm> using namespace std; int a,b,c,x,y; int main() { scanf("%d %d %d",&a,&b,&c);
for(int i=1;i<10001;i++) { x=0; y=0;
for(int j=1;j<=(int)sqrt((double)i)+1;j++) if(i%j==0) x++;
if(i-c>0) { for(int j=1;j<=(int)sqrt((double)(i-c))+1;j++) if(i%j==0) y++; }
if(b==x && a==y) {printf("%d",i);getchar();getchar();return 0;} }
printf("0");system("Pause"); } | | Accepted (sudo rm -rf) | Dan | 1877. Bicycle Codes | 8 Feb 2013 01:34 | 2 | //SESC USU SUDO RM -RF var a,b,c,d,i:integer; begin readln(a); readln(b); for i:=1 to 10000 do begin if i mod 2 = 0 then if b-c <> 0 then c:=c+1 else d:=d+1 else if a-c <> 0 then c:=c+1 else d:=d+1; end; case d of 1..200000 : writeln ('yes'); 0 : writeln ('no'); end; end. Edited by author 01.12.2012 17:39 Edited by author 01.12.2012 17:39 Edited by author 01.12.2012 17:39 | | wa3? | mediant | 1877. Bicycle Codes | 8 Feb 2013 01:29 | 1 | wa3? mediant 8 Feb 2013 01:29 var a,b:integer; begin if(a mod 2 =1) or (b mod 2=0) then writeln('no') else writeln('yes') end. or wa1? var c,d : integer; a,b : string[4]; begin readln(a); readln(b); val(a,c); c:=c mod 2; val(b,d); d:=d mod 2; writeln(c,d); if (c=1) or (d=0) then writeln('no') else writeln('yes'); end. | | To Admin. Test #3 is wrong | ilya trofimov | 1914. Titan Ruins: Serial Control | 7 Feb 2013 19:56 | 3 | Why? You can rotate the only accessible ring 1/2 turns, and the second ring will stay in its initial position. | | test17 | Hanzbrow (TNU) KCC | 1748. The Most Complex Number | 7 Feb 2013 04:11 | 4 | test17 Hanzbrow (TNU) KCC 30 Jan 2010 00:59 really curious about it, do you have any idea? Am I right? 19 1 1 1 10 6 4 100 60 12 1000 840 32 10000 7560 64 100000 83160 128 1000000 720720 240 10000000 8648640 448 100000000 73513440 768 1000000000 735134400 1344 10000000000 6983776800 2304 100000000000 97772875200 4032 1000000000000 963761198400 6720 10000000000000 9316358251200 10752 100000000000000 97821761637600 17280 1000000000000000 866421317361600 26880 10000000000000000 8086598962041600 41472 100000000000000000 74801040398884800 64512 1000000000000000000 856811873911587456 491520 No, for 10^18 correct answer is 897612484786617600 103680 Try using unsigned long long and compute the numbers untill 10^19 | | Is there linear time algorithm which solves the problem? | [SPb NRU ITMO] Niyaz Nigmatullin | 1635. Mnemonics and Palindromes | 7 Feb 2013 01:35 | 1 | |
|
|