Show all threads Hide all threads Show all messages Hide all messages |
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". |
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 |
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 |
|
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. |
is there good solution of the problem (not backtracking or heuristics)?(-) | xdex | 1040. Airline Company | 15 Sep 2008 19:46 | 3 |
Yes. Get a chain, paint it CUR...CUR+X. That's not everything, but a good start to get fair AC in 0.001 sec. I can find any polynomial algorithm but use some logics(AC). Can somebody tell normal algorithm. My mail piratic@mail.ru |
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... |
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... |
Wrong Sample input and Output ? Please help me . | Nguyen Viet Bang | 1040. Airline Company | 1 Feb 2008 05:07 | 3 |
Please consider the Sample input and output : The 1st flight ( connects 1 and 2 ) and the 2-nd flight ( 2-3) are flights that depart from one airport ( airport 2 ) ( The flight are 2 directions flight ) . But the sample output indicates that their numbers are 4 and 2 , so their greatest common divisor can't be 1 as the problem description ! I don't know if I wrong . I got WA too . Please explain for me Thanks a lot ! . You must calculate greatest common divisor of all flights, that departs from one airport. For airport 2 this numbers are 2,3,4 and there greatest common divisor is 1. |
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 |
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. |