Show all threads Hide all threads Show all messages Hide all messages | Why WA test #3 ? | Vladimir Li | 1211. Collective Guarantee | 22 Feb 2007 17:20 | 1 | Can you give me test 3 Edited by author 22.02.2007 17:21 | WA#3 can't understand why? | Denis Vl | 1211. Collective Guarantee | 27 Jul 2006 01:10 | 1 | Help plz.... [code deleted] Edited by moderator 28.07.2006 10:35 | 2Admins. Why don't you write the problem correct | SPIRiT | 1211. Collective Guarantee | 21 Jan 2006 21:29 | 2 | It's said here that the witness is noncontradictory if E X A C T L Y one child sayd it was him, and there was no circle. But it's not true. In test 3 there is more one child who said it was him, and still it was considered noncontradictory. Actually it sounds like this: "At least one child said it was him and there was no circle" In fact it's wrong! I've read your message and got WA two times!!! It have to be exactly one child said it was him! | Correct idea is HERE | Vlad Veselov | 1211. Collective Guarantee | 29 Jul 2005 02:36 | 6 | Use two arrays: Ans,Status : Array [1 .. 25000] Of Word; Ans is answers of children, Status is current status of every of them. First Status = DUP(0), and then Status[i] = 0 - if child i have unknown status 1 - if child's answer is "Me!!!" k - if we marked him(or her) on step k(k >= 2) In every iteration we searching for child with unknown status(p). If his(or her)answer is "Me" we making his(or her) status equal to 1, else we mark him(or her) with k and going to check child Ans[p]. If we meet status=k in our checking then cycle is found. Else we continue this process until we can find child with status = 0. Don't forget calculate children with status = 1. My solution on Pascal got AC with 0.62 sec., 127K. P.S. Sorry for bad English. /*AC*/ double time = 0.14; long memory = 349; //КБ return; I am not use your idea!!! No optimization!!! Edited by author 25.07.2005 14:03 Edited by author 25.07.2005 14:04 Edited by author 25.07.2005 14:05 885512 02:26:18 29 июл 2005 Tolstobrov_Anatoliy[Ivanovo SPU] 1211 Pascal Accepted 0.062 223 КБ Who can better???? Oh foget!! Tolstobrov_Anatoliy[Ivanovo SPU] 29 Jul 2005 02:36 I USE const coll=25000; var m:array[0..coll]of word; z,b:array[0..coll]of boolean; t,i,k,j,n:word; kk,gg,bb:boolean; | Why wa #3? | Maigo Akisame (maigoakisame@yahoo.com.cn) | 1211. Collective Guarantee | 24 May 2005 19:04 | 2 | Why wa #3? Maigo Akisame (maigoakisame@yahoo.com.cn) 25 Sep 2004 16:28 program ural1211; const maxn=25000; var next:array[1..maxn]of word; t,i:word; procedure test; var sign:array[1..maxn]of word; n,i,x:word; zeros:byte; begin read(n);zeros:=0; for i:=1 to n do begin read(next[i]); if next[i]=0 then begin inc(zeros); if zeros>1 then break; end; end; if zeros<>1 then begin writeln('NO'); exit; end; fillchar(sign,sizeof(sign),0); for i:=1 to n do begin x:=i; while x>0 do begin if sign[x]=i then begin writeln('NO'); exit; end else if sign[x]>0 then break; sign[x]:=i;x:=next[x]; end; end; writeln('YES'); end; begin read(t); for i:=1 to t do test; end. I too get WA#3 to this one, here is my C solution: #include<stdio.h> #define true 1 #define false 0 main() { int parent[25001] , T , temp , temp2 , temp3 , test; int N , answer , cur; int confess , resolved; scanf("%d" , &T); for(test = 1 ; test <= T ; test++) { scanf("%d" , &N); confess = resolved = false; for(temp = 1 ; temp <= N ; temp++) parent[temp] = -1; for(temp = 1 ; temp <= N && resolved == false ; temp++) { scanf("%d" , &answer); if(answer == 0) { if(confess) { printf("NO\n"); resolved = true; } else confess = true; } else { cur = temp; while(cur != -1 && cur != answer) cur = parent[cur]; if(cur == answer){ printf("NO\n") ; resolved = true; } else parent[answer] = temp; } } if(resolved == false) printf("YES\n"); for( ; temp <= N ; temp++) scanf("%d" , &answer); } } Edited by author 24.05.2005 19:04 | what answer for | Виктор Крупко | 1211. Collective Guarantee | 17 May 2005 11:24 | 3 | NO (Cycle: 3,1) NO (Cycle: 4,3,2) | HELPPPPPPPP. TL PLEASE | I am david. Tabo. | 1211. Collective Guarantee | 29 Oct 2002 22:19 | 2 | var ni,k,i,j,max,m,n:longint; a,b:array [1..25001] of integer; q:array [1..1001] of byte; s:boolean; begin readln (k); for j:=1 to k do begin readln (n); for i:=1 to n do begin if i<>n then read (a[i]) else readln (a[i]); if a[i]<>0 then inc (b[a[i]]); end; max:=b[1]; for i:=2 to n do if max<b[i] then max:=b[i]; for i:=1 to n do if (b[i]=max) then inc (m); ni:=0; if m=1 then begin q[j]:=1; s:=true; end else for i:=1 to n do if (a[i]=0)and(b[i]<>0) then begin q[j]:=1; if ni=1 then begin q[j]:=0; break; end; inc (ni); s:=true; end; if not s then q[j]:=0; s:=false; fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); end; for i:=1 to k do if q[i]=1 then writeln ('YES') else writeln ('NO'); end. You need to use the O(n) algo. Here is my AC solution. It checks if the graph is the tree. If is then YES. program Collective_Guarantee; const MaxN=25000; label fin; type List=array[1..MaxN] of Integer; var Tree,Sign:List; N,i,j,z,K,M,m1:integer; res:boolean; begin readln(M); for m1:=1 to M do begin readln(N); z:=0; res:=true; for i:=1 to N do begin read(Tree[i]); if Tree[i]=0 then inc(z); end; if z<>1 then begin res:=false; goto fin; end else begin FillChar(Sign,SizeOf(Sign),0); K:=0; while true do begin i:=1; inc(K); while (Sign[i]>0) and (i<=N) do inc(i); if i<>N+1 then begin while i<>0 do begin if Sign[i]=0 then Sign[i]:=K else if Sign[i]=K then begin res:=false; goto fin; end else if Sign[i]<K then i:=0; if i<>0 then i:=Tree[i]; end; end else goto fin; end; end; fin: if res=false then writeln('NO') else writeln('YES'); end; end. |
|
|