Show all threads Hide all threads Show all messages Hide all messages |
Page 2 |
If you get WA #5 (and hints for the question | Myrcella | 1040. Airline Company | 13 Sep 2018 17:33 | 1 |
I think of "N<=50" as "N,M<=50". Actually M<=N*(N-1)/2. It's a stupid mistake but it took me so much time to check out TAT (btw, the point to solve the question is GCD(x,x+1)=1, it can be proved that the answer is always "YES". |
The graph can be not connected ?! | Vladislav | 1040. Airline Company | 5 Nov 2011 12:40 | 2 |
When I make my algo work for not connected graphs, i got AC. (I changed dfs(0) to for(int i=0;i<n;++i)if(!lev[i])dfs(i); ) |
No subject | Macarie | 1040. Airline Company | 22 Jul 2011 22:35 | 1 |
|
~.~! M >= 50 :0 | lshain | 1040. Airline Company | 14 Jun 2011 15:44 | 1 |
|
A possible test data. | kiko | 1040. Airline Company | 22 May 2015 17:17 | 2 |
4 4 1 2 2 3 3 1 1 4
One possible answer is: YES 1 2 3 4 Thank you a lot, this problem took me so much time |
connected or not? | hoan | 1040. Airline Company | 10 Oct 2010 00:22 | 1 |
i got AC but my code is correct when is graph is connect, who can solve this when the graph is arbitary? plz give me your code. (sorry for bad english) :D |
The trick is here : gcd ( x , x + 1 ) = 1 | Phan Hoài Nam (HUFLIT) | 1040. Airline Company | 9 Oct 2010 00:04 | 1 |
This problem is so easy ^^! |
Is 1,2,4,6,5,3 also right?????????? | bobchennan | 1040. Airline Company | 22 Jul 2010 09:52 | 3 |
Who can tell me? I have WA1. Thanks a lot. Edited by author 03.05.2009 09:55 Edited by author 03.05.2009 09:56 Edited by moderator 13.05.2009 01:51 "If there are several flights that depart from one airport then the greatest common divisor of their flight numbers should be equal to 1." input 6 6 1 2 2 3 2 4 4 3 5 6 4 5 output 1 2 4 6 5 3 This output isn't correct because for second flight (2, 3) gcd is equal to 2 != 1. Edited by moderator 13.05.2009 01:52 O_o "If there are several FLIGHTS that depart from one AIRPORT then the greatest common divisor of their flight numbers should be equal to 1." Why did you calculate gcd for the second flight? Output is a numbers of flights, not numbers of flights. May be you should do this for the second airport. However gcd of the flight numbers of the second airport is gcd(1,2,4) = 1. P.S. I think output is not right because gcd of the flight numbers from the airport #3 is equal to 2. Edited by author 22.07.2010 10:00 |
Problem 1140 "Airline company" has been rejudged (+) | Vladimir Yakovlev (USU) | 1040. Airline Company | 28 Dec 2008 02:34 | 1 |
Bad test #13 has been corrected, solutions that had troubles with this test have been rejudged. 23 authors have got AC. |
I think it is Hamilton way | [FoH]^^richman^^ | 1040. Airline Company | 26 May 2008 19:55 | 2 |
find the way from one to all airports and each airport can be passed one time Edited by author 24.05.2008 19:16 No, just think a bit - and you'll find more beautiful solution... |
HOW COME? | Dmitry "Logam" Kobelev | 1040. Airline Company | 14 Jan 2008 15:18 | 2 |
HOW COME? Dmitry "Logam" Kobelev 3 Jan 2008 22:31 Why cant we just output first M prime numbers??? WA1 #include<stdio.h> #include<math.h> void main() {int n,h; bool f; scanf("%i%i",&n,&n); printf("YES\n1"); for(int i=2,j=1;j<n;i++) {h=(int)sqrt((float)i); f=0; for(int k=2;k<=h;k++) if((i%k)==0) {f=1;break;} if(!f){printf(" %i",i);j++;} } } Because numbers must be [1..M] |
WHY WA#1???(+) | Oracle | 1040. Airline Company | 28 Sep 2007 01:10 | 1 |
AC!!!!! Edited by author 06.08.2008 18:53 |
Problem 1140 "Airline company" has been rejudged (+) | Sandro (USU) | 1040. Airline Company | 26 Oct 2006 18:55 | 3 |
Validator was updated and some new tests were added. Many authors got WA and TL because their heuristics failed new tests. Try to find new tricky tests if your heuristics still has AC. Does your solution can pass ALL kinds of tests under this constraints? Yes (-) Vladimir Yakovlev (USU) 26 Oct 2006 18:55 |
What's the answer of this input? | davidsun | 1040. Airline Company | 13 Aug 2006 14:12 | 2 |
6 5 1 2 2 4 4 3 5 6 3 2 Is the answer YES 4 1 2 5 3 right? I've got AC. The problem is very strange. I initial the numbers(give every edge a number), and got AC at last. It took me a long time! |
Test 6 is wrong! | :) | 1040. Airline Company | 26 May 2006 00:33 | 5 |
The graph is not connected. Incorrect.Sine dubitatibus. Fixed (+) Vladimir Yakovlev (USU) 26 May 2006 00:33 some submissions since 20-Feb-2006 have been rejudged and got AC Edited by author 26.05.2006 01:31 |
Page 1 |
Test 6 | Christos Mantoulidis | 1040. Airline Company | 19 Mar 2006 15:50 | 1 |
Test 6 Christos Mantoulidis 19 Mar 2006 15:50 Can someone post test 6? Thanks |
2Admins (!) tests are incorrect | Burunduk1 | 1040. Airline Company | 19 Feb 2006 23:41 | 5 |
Please, explain me why answer is always YES? It's right only for connected graphs! For example: 6 6 1 2 2 3 3 1 4 5 5 6 6 4 Answer is NO. Oh, what a trick! I was very much confused seeing > 400 people who solved this problem. I'm really annoyed beacuse in this case the problem is O(n + m) using a simple idea gcd(n,n + 1) = 1. But if the graph can be disconnected everything is much worse!!! Graph can be disonnected. Sample is. But testset is weak... Why am I not surprised :) My always "YES" program got AC. With such tests the problem is much easier than it is. Please, change tests or statements! Fixed (+) Vladimir Yakovlev (USU) 19 Feb 2006 23:41 Graph is always connected now. Statements and tests are updated. So, the solution always exists. |
AC solution is incorrect! | UNKNOWN_LAMER | 1040. Airline Company | 22 Dec 2005 14:53 | 3 |
Submit ID is 1027752. For test 5 4 1 2 2 3 1 3 4 5 My answer is NO. But you can number flights: 1 2 3 4 :) My solution should be OK for connected graphs. But the test set lacks for disconnected cases. I have re-read and could't find my mistake. Can you help me? And I've found the case of connected graph with WA. 5 6 1 2 1 4 2 4 3 4 4 5 3 5 My solution's answer is NO, but 2 1 3 4 6 5 seems to be OK. So the test set of Timus is really incomplete. |
Who can give me some tests for my program? | huangjinsong | 1040. Airline Company | 16 Jul 2004 10:32 | 1 |
var line:array[1..2500] of record x,y:integer; end; d,c:array[1..50] of integer; path:array[1..2500] of integer; a,b:array[1..50,1..50] of integer; use:array[1..2500] of boolean; i,j,n,m:integer; Function Gcd(a,b:integer):integer; begin if a mod b=0 then Gcd:=b else Gcd:=Gcd(b,a mod b); end; Function OK(k:integer):boolean; var i,j:integer; begin OK:=true; if (d[k]<=1) then exit; j:=a[k,1]; for i:=2 to d[k] do begin j:=GCD(j,b[k,a[k,i]]); if j=1 then exit; end; OK:=false; end; Procedure Print; begin writeln('YES'); for i:=1 to m-1 do write(path[i],' '); writeln(path[m]); halt; end; Procedure Get(k:integer); var i:integer; begin if k=m+1 then Print; for i:=1 to m do if use[i] then begin path[k]:=i; use[i]:=false; b[line[k].x,line[k].y]:=i; b[line[k].y,line[k].x]:=i; inc(c[line[k].x]); inc(c[line[k].y]); if c[line[k].x]=d[line[k].x] then if OK(line[k].x) then if c[line[k].y]=d[line[k].y] then if OK(line[k].y) then Get(k+1) else else Get(k+1) else else if c[line[k].y]=d[line[k].y] then if OK(line[k].y) then Get(k+1) else else Get(k+1); use[i]:=true; dec(c[line[k].x]); dec(c[line[k].y]); end; end; begin // assign(input,'1040.in'); reset(input); readln(n,m); fillchar(d,sizeof(d),0); for i:=1 to m do begin readln(line[i].x,line[i].y); inc(d[line[i].x]); inc(d[line[i].y]); a[line[i].x,d[line[i].x]]:=line[i].y; a[line[i].y,d[line[i].y]]:=line[i].x; end; fillchar(use,sizeof(use),true); fillchar(c,sizeof(c),0); Get(1); writeln('NO'); end. |
We can construct the answer from the input in O(nm) time | ahyangyi_newid | 1040. Airline Company | 3 Feb 2008 18:30 | 9 |
Sorry, my english is too poor to describe my algo. But here is a little tips: For any neighbor positive integers a & b: GCD(a,b)=1 I.E. GCD(1,2)=1 GCD(2,3)=1 GCD(3,4)=1 GCD(4,5)=1 GCD(5,6)=1 GCD(6,7)=1 GCD(7,8)=1 GCD(8,9)=1 GCD(9,10)=1 ...... See this: 6 6 1 2 2 3 3 1 4 5 5 6 6 4 The answer is NO But there are no data like this... I got AC although my program always prints "YES"... is there an algo wich works in O(n+m) for disconnected graphs too? I think no. For exmaple, sometimes answer is NO and strategy 1,2,3,4... doesn't work. When statements were incorrect (it was not said that graph is connected) I and some my friends tried to solve it... but we couldn't find even polynomial solution. So I think no. If graph is connected ( current statement ), problem can be solved by dividing graph into chains ( like in #1441 ), chains are: k,k+1,...,l . This solution is absolutely correct. No, I think the answer is 3 4 1 2 6 5 Sorry,I think your answer is wrong. See the node 5:the number of one egde is 2,another is 6,gcd(2,6)=2<>1 I think we can get the answer in O(n+m)... Just use the method you mentioned... Each node has two arcs which numbered x and x+1... |