Can you give me any hint or any tests? Thanks in advance. I also WA5. When I consider K > 1000, I got AC. The graph is directed i.e. 8 is connected to 5 but 5 is not connected to 8. So that means if the input is 1 8 5 8 5 6 then the answer will be impossible. Edited by author 30.11.2010 02:14 Why always getting mle on #2 In this problem,many people use the BFS(breadth first search).However,you can't search it from the two numbers which are in the last line,you should search it from the plate you need.Because of this,I was wrong before at test#6. If your can't understand it,you can test the sample input,the right answer is- 2 1 2 but not 2 4 2 And pay attention at the number of routes-1 to 2000. Believe me!!! Sorry to my English...I'm a Chinese... Good luck to you.:) =。= Why you say that? You should say "Sorry to my English...I'm a Japanese..." I ACed it with BFS first try! It took me 15 minutes to solve :\ What are you talking about? ~~~MY SOLUTION STAT~~~ Points nullified : 1) BFS doesn't work! 2) You can't search from the starting point. 3) Right answer isn't 2 4 2 Additional points : INCONSISTENCY NULLIFICATION : 0 corresponds to YOUR plate! Hope I made your "advice" invalid. The key point is to build the graph (I did in K^2) and traverse it with BFS, so that you could find the SHORTEST path (K). That gives me O(K^2) in total. Edited by author 13.03.2018 18:05 I used Djkstra search. Why didn't this work? By the way, is 1<=K<=1000 or K may become zero or negative? What's wrong? Can anyone give me a test The k can't be negative, it means the number of the plat. My AC probram gets on samle test output 2 2 1 However this is an output of reversed sequence. It is even imposible to change 1/8 to 5/4. Good output: 2 1 2 What is more, in the problem statement is not written that any one shortest way of changing can be printed. Even for sampe test there are 2 way of solving it. Sorry for mine English. Thank you for help! Validator of this problem was fixed. Rejudge is finished. 56 AC verdicts turned to WA, but 12 WA got AC. IMO, tests are still incorrect. My program got TLE #10 after such debug submit: // some code here ... int m; void TLE(){ while(1); } int main(){ scanf("%d ",&m); if(m > 1000) TLE(); int u,v,x,a,b; REP(i,m){ scanf("%d %d ",&u,&v); if(u <1 || u > 2000) TLE(); // some code here } // some code here return 0; } Without assertions it got Crash #10... You are right! There was a route number 0 in several tests. Tests are fixed. The wrong verdicts will be rejudged. My AC solution give wrong (I think so) answer on this test: 4 6 8 5 4 7 4 1 5 6 1 8 Answer: 1 1 But we cannot do it. Solution means that we give our plate "1 8" to the driver of the 1st bus and he gives us plate "6 8". But his route is 6 and he gets "1 8". So his plate now doesn't correspond to its route. In statement is said "Any driver will agree to change his plate for another only if this plate has the number of his route". "1 8" doesn't have 6. Send me the code, please! goldenxbullet@gmail.com Thanks! Maybe those tests are not correct in 100% but answers are are good ;) 11 8 4 3 5 10 3 5 1 2 9 1 4 8 4 9 6 9 10 9 2 6 9 5 6 9 ################################### 3 9 3 2 9 8 5 8 2 7 10 9 10 1 4 1 9 9 7 3 8 4 8 8 1 5 ############################## 2 5 9 9 3 6 4 6 4 9 5 1 2 4 10 8 5 7 8 4 6 2 1 9 5 #################################### 1 4 I've checked my program many times, but I didn't see any mistake in it Maybe you can see Thanks const inf=2005; var i,j,x,k,need,sh,zn,num:integer; fir,sec,op,h:array[1..1000]of integer; g,put:array[1..1000,1..1000]of integer; f:boolean; procedure deikstra; begin while (sh<k+1)do begin zn:=inf; num:=-1; for i:=1 to k+1 do begin if (op[i]<zn)and(h[i]=0)then begin zn:=op[i]; num:=i; end; end; if (num=-1)then exit; h[num]:=1; inc(sh); for i:=1 to k+1 do begin if (g[num,i]=1)and(op[i]>op[num]+1)and(h[i]=0)then begin op[i]:=op[num]+1; for x:=1 to op[num] do put[i,x]:=put[num,x]; put[i,op[i]]:=num; if (fir[i]=need)or(sec[i]=need)then begin writeln(op[i]); for x:=2 to op[i] do writeln(put[i,x]); write(i); f:=true; exit; end; end; end; end; end; begin read(k); for i:=1 to k do read(fir[i],sec[i]); read(need,fir[k+1],sec[k+1]); for i:=1 to k+1 do begin for j:=1 to k+1 do begin if ((fir[i]=fir[j])or(fir[i]=sec[j]))and(i<>j)then begin g[j,i]:=1; end; end; end; for i:=1 to k+1 do op[i]:=inf; op[k+1]:=0; sh:=1; f:=false; deikstra; if (f=false)then write('IMPOSSIBLE'); end. When I change: >fir,sec,op,h:array[1..1000]of integer; >g,put:array[1..1000,1..1000]of integer; into: fir,sec,op,h:array[1..1050]of integer; g,put:array[1..1050,1..1050]of integer; and >const inf=2005; into: const inf=100000; I get AC Maybe you'll check Test#16 I also had problem with test 16. I had a bug: my program couldn't work with number of rout 2000. may be you forgot <= 1000 but not < 1000?? Who can give me some test to debug WA#2? I can't found, where is mistake? try this, I hope helps you... it helped me :) 3 1 3 3 5 7 5 7 3 6 The answer is IMPOSSIBLE why the answer is IMPOSSIBLE ?? 3 1 3 3 5 7 5 7 3 6 your answer must be : 2 2 1 but take notice of one point that the second number which are given isn't the route the driver is driving. so you can't change the board with the third driver. sorry of my bad English. I use BFS. Main idea is rather simple. I have rewrited my program 2 times, but still WA#8 Edited by author 02.07.2009 20:30 any one can give me some tips? what's the test1 is ?? thx, i have rewritten it and got ac....but i still dont know why.... 1 1 3 3 2 1 ANSWER: 1 1 but 1 3 1 3 2 1 ANSWER: IMPOSSIBLE what data for this test??? writeln('IMPOSSIBLE'); You forgot it... It seems we must output the shortest way of changing,but in the problem says: If there are several solutions, you can output any one. isn't it wrong? sorry for my english. "Help the new driver to find a SHORTEST sequence of changes that will enable him to get a plate with the number of his route" I use BFS in the program #include<iostream.h> long x[2000],y[2000]; int queue[2000]; int parent[2000]; int path[2000]; int in[2000]; void main() { int n; int i,j,tot,current,step; int temp; long need; cin>>n; for(i=1;i<=n;i++){ in[i]=0; cin>>x[i]>>y[i]; } cin>>need>>x[0]>>y[0]; queue[0]=0; current=0; tot=1; while(current<tot){ if(x[queue[current]]==need||y[queue[current]]==need) break; for(i=1;i<=n;i++){ if(!in[i]){ if((x[i]==x[queue[current]])||(x[i]==y[queue [current]])||(y[i]==x[queue[current]])||(y[i]==y[queue[current]])){ queue[tot]=i; parent[i]=queue[current]; in[i]=1; tot++; } } } current++; } if(x[queue[current]]==need||y[queue[current]]==need){ step=0; temp=queue[current]; while(1){ if(temp==0) break; step++; path[step]=temp; temp=parent[temp]; } cout<<step<<endl; for(j=step;j>=1;j--){ cout<<path[j]<<endl; } }else{ cout<<"IMPOSSIBLE"<<endl; } } when i change if((x[i]==x[queue[current]])||(x[i]==y[queue[current]]) ||(y[i]==x[queue[current]])||(y[i]==y[queue[current]])) {} into if((x[i]==x[queue[current]])||(x[i]==y[queue[current]]) {} i get ac. i did not read the problem carefully Anyone who got wrong answer should pay attention to it Thanks! But where it is mentioned in the problem statement??? Another THANKS from me, but really where is that mentioned in the problem's statement ? THANKS, man!
Well, there is a sentence in text: "The next K lines contain the number of the route of the corresponding bus and the number on the other side of its plate." But it is not explicitly said that first number in line is route number and that second number is from the other side of plate... Anyway, the point is that you can change your plate with driver i (which has plate x[i],y[i]) iff one of the numbers on your plate is x[i] (not x[i] OR y[i]). Thanks to sb. I WA first.But I AC after I knew K might >1000 !!!!! Be careful! I got AC using data[1000]; So there aren't any K>1000 Probably you forgot that the ID of a route can be more than 1000. In the problem do not written how much defferent routes are availble!!! Yes, what about limits of max route? 1096 Pascal Accepted 0.015 116 КБ 986195 20:09:06 4 Nov 2005 Chidori 1096 Pascal Accepted 0.001 249 KB |
|