Common BoardNo. No test have the same word twice by the condition of the problem. Following tests are not correct(It's fact I got AC) 1.abc f abc 2.a a a a a .... This is my code, help me with some wrong tests , please ^^ Program Tree2; Uses Math;//,crt; Const Finp ='';// Fout =''; Maxn =20001; Type Pt =^rc; rc=Record v:Longint; Next:Pt; End; Var fi,fo :Text; n,k,Low,S,T:Longint; List :Array[1..Maxn] of Pt; A,C,tr,v1,v2,Q,B,F:Array[1..Maxn] of Longint; Free :Array[1..Maxn] of Boolean; Procedure OpenFile; Begin Assign(fi,finp); Reset(fi); Assign(fo,fout); Rewrite(fo); End; Procedure CloseFile; Begin Close(fi); Close(fo); End; Procedure Push(v:Longint; Var Next:pt); Var p:pt; Begin New(p); p^.Next:=Next; p^.v:=v; Next:=p; End; Procedure Readinp; Var u,v:Longint; Begin Readln(fi,n,k); If n=1 Then Begin For k:=1 to k do Begin Read(fi,u,v); If v=0 Then WRiteln(fo,1) else Writeln(fo,0); End; CloseFile; Halt; End; For n:=1 to n do List[n]:=Nil; For n:=2 to n do Begin Readln(fi,u,v); Push(u,List[v]); Push(v,List[u]); End; End; Procedure Dfs(i,x:Longint); Var p:Pt; v:Longint; Begin If Low < x Then Begin Low:=x; S:=i; End; Free[i]:=False; p:=List[i]; While p<> Nil do Begin v:=p^.v; If Free[v] then Begin Tr[v]:=i; Dfs(v,x+1); End; p:=p^.Next; End; End; Procedure Prepare; Var i,x:Longint; Begin Fillchar(Free,sizeof(Free),True); Dfs(1,0); Low:=0; T:=S; Fillchar(Free,sizeof(Free),True); Fillchar(Tr,sizeof(Tr),0); DFS(T,0); i:=S; x:=1; C[S]:=1; B[1]:=S; While True do Begin i:=Tr[i]; Inc(x); C[i]:=x; B[x]:=i; If i = T Then Break; End; End; Procedure Solve; Var i,x,dau,cuoi,w,v:Longint; p:pt; Begin Inc(Low); For i:=1 to Low do Begin x:=b[i]; dau:=0; cuoi:=1; Q[1]:=x; While dau <> cuoi do Begin Inc(dau); w:=Q[dau]; p:=List[w]; While p<> Nil do Begin v:=p^.v; If (C[v]=0) Then if (v1[v]=0) Then Begin v1[v]:=x; v2[v]:=v2[w]+1; Inc(cuoi); Q[cuoi]:=v; End; p:=p^.Next; End; End; End; End; Function Found(k,u,l:Longint):Longint; Var dau,cuoi,v,x:Longint; p:Pt; Begin dau:=0; cuoi:=1; F[u]:=0; Q[1]:=u; Tr[u]:=k; While dau<> cuoi do Begin Inc(dau); x:=Q[dau]; p:=List[x]; While p<> Nil do Begin v:=p^.v; If Tr[v] <> k Then Begin F[v]:=F[x]+1; Tr[v]:=k; Inc(cuoi); Q[cuoi]:=v; If F[v]=l Then Exit(v); End; p:=p^.Next; End; End; Exit(0); End; Procedure Answer; Var u,v,x,Ans:Longint; Begin Fillchar(tr,sizeof(Tr),0); For k:=1 to k do Begin Readln(fi,u,v); If v >= Low Then Begin Writeln(fo,0); Continue; End; If C[u] <> 0 Then Begin If v + C[u] <= Low Then Begin v:=v+ C[u]; Writeln(fo,B[v]); Continue; End; If v<C[u] Then Begin v:=C[u]-v; Writeln(fo,B[v]); COntinue; End; Writeln(fo,0); Continue; End; If v2[u]=v Then Begin Writeln(fo,v1[u]); Continue; End; If V2[u] < v Then Begin x:=C[v1[u]]; If x > v - V2[u] Then Begin x:=x-(v - v2[u]); Writeln(fo,B[x]); Continue; End; If x + (v- v2[u]) <= Low Then Begin x:=x+(v-v2[u]); Writeln(fo,B[x]); Continue; End; Writeln(fo,0); Continue; End; x:=Found(-k,u,v); Writeln(fo,x); End; End; Function Dist(u,l:Longint):Longint; Var dau,cuoi,v,x:Longint; p:Pt; Begin dau:=0; cuoi:=1; F[u]:=0; Q[1]:=u; Tr[u]:=k; While dau<> cuoi do Begin Inc(dau); x:=Q[dau]; p:=List[x]; While p<> Nil do Begin v:=p^.v; If Tr[v] <> k Then Begin F[v]:=F[x]+1; Tr[v]:=k; Inc(cuoi); Q[cuoi]:=v; If v=l Then Exit(F[v]); End; p:=p^.Next; End; End; Exit(0); End; Procedure Test; Var u,v,l,x:Integer; Begin Assign(fi,finp); Reset(fi); Assign(fo,fout); Reset(fo); Readln(fi,n,k); For n:=2 to n do Readln(fi,u,v); For k:=1 to k do Begin Readln(fi,u,l); Readln(fo,v); If v=0 Then Begin x:=Found(-k,u,l); If x<>0 Then Begin Writeln('sai'); Exit; End; COntinue; End; x:=Dist(u,v); Writeln(x,' ',l); If x<>l Then begin Writeln('Sai'); Exit; End; End; End; Begin // Clrscr; Openfile; Readinp; Prepare; Solve; Answer; CloseFile; // Test; End. give me some tests , please ! up This test help me 10 1 1 2 2 3 3 4 4 5 1 6 6 7 1 8 8 9 9 10 10 7 Is it possible to solve it in Java without any special tricks? I got MLE #16 any time when I submitted it in Java. Of course, the same C++ code gets AC and uses 35 MB. I think that it is not good when equal solutions get different verdicts. Am I right? Admins, maybe you should increase memory limit? Edited by author 01.11.2010 10:11 Maybe you have problem with huge amount of strings while construct graph. std::string is mutable, but java.lang.String is immutable and you not call garbage collector for removing unnecessary copies. Java solution without strings require only 12MB http://acm.timus.ru/status.aspx?space=1&num=1806&author=38899I used strings only for reading input (not too much memory), then I used arrays of byte to store numbers and longs to keep them in map. Your 12 MB solution is too perfect :) Many other C++ solutions use about 40 MB and, rewritten in Java, they will be MLE. It means that C++ and Java are not equal in their opportunities for this problem. I don't like this. And you? By the way, Saratov provides programmers 256 MB for each problem. Why Timus can not do the same? Do not create the whole graph forward, just get the neighbours for the current vertex which is already removed from heap, this is the only trick :). I've got AC with standard java HashMap and PriorityQueue. wont it give tl if each step you go through 50000 neighbours. About n*n/2 in worth case Each vertex has at most 135 neighbours. ur right accepted. Thanks. Thanks to KALO too for the help. Edited by author 09.11.2010 00:31 Can drunk King make the first and the last moves in the same direction? No comments if "NO COMMENTS" why you write this? information - Zero King cannot do that because the move to the corner and the move from that corner cannot be the same direction. It's really easy!!! var n,m:real; begin readln(m,n); writeln((m*n-m-n-1+sqrt(2)*(n+m+1)):0:12); end. Pascal forever!!! FFFFUUUU~. It's not Pascal, it's just Math!!1 how did you get to the formula? m*n-m-n-1+sqrt(2)*(n+m+1) 87 authors lost AC after rejudge. Good luck! More tests were added. Read site news. I got AC but i have a question: why when i use: int f(char **v){ . . . } int main (){ char m[5][5]; f (m); } my code have compile error. and when i use : int f(char v[][5]){ . . . } int main (){ char m[5][5]; f (m); } it's correct. is'nt the type of m char **? if "yes" what's the type of m? sorry for my poor english. Edited by author 07.11.2010 21:51 What the hell? I use BFS, all tests given here my program answers correct, but WA1! What could it be? Oh, I finally had done it... The first idea wasn't good. Just another BFS AC'es. // zadachki.cpp: определяет точку входа для консольного приложения. // #include <iostream> #include "vector" using namespace std; int main() { int n; double t; vector<double>x; vector<double>y; cin>>n; for(int i=0; i<n; i++) { cin>>t; x.push_back(t); cin>>t; y.push_back(t); } for(int i=0; i<n;i++) { double m=((x[(i+1)%n]-x[i])*(y[(i+2)%n]-y[(i+1)%n])-(x[(i+2)%n]-x[(i+1)%n])*(y[(i+1)%n]-y[i])); if (m>0) {cout<<"ccw"; return 0;} if (m<0) {cout<<"cw"; return 0;} } return 0; } WHY? Can anyone let me 7 test... sorry... 10 test Edited by author 07.11.2010 16:53 Whith n>4 Edited by author 27.06.2009 12:40 5 -- 22112 6 -- 122112 7 -- 2122112 8 -- 12122112 9 -- 212122112 10 -- 1212122112 (Maybe it will be useful for someone ^_^") I use one array of int. It size is 256. Good luck!!! Let me test 4 Edited by author 07.11.2010 00:25 I assume the percentage is'nt exceed 100% and i got AC, this is a rule of problem or in any way we can prove this??? sorry for my poor english. I have WA at test #72. Could I get content of this test? Pls :) Edited by author 07.11.2010 22:46 in each turn you must take x stones which x is a member of S= {1, 2^1, 2^2, ...} sorry for my poor english. Chess notation in this problem is standard chess notation. But the statement can be unclear because "forward side" of cube here means "nearest" to us (to 1st row). I've changed "forward side" to "near side" and "backward side" to "far side". Does it make the statement better? Maybe it is even better to describe "near side" as the one facing the first row, but the new version is also good enough. Please, add new tests to problem 1005. for input 4 10 11 13 15 submit number 3269083 returns 1 and submit number 3270969 returns 3 and both of them have been accepted. Thx. |
|