Show all threads Hide all threads Show all messages Hide all messages |

Another approach | andreyDagger | 1134. Cards | 11 Aug 2021 18:10 | 1 |

Actually, you can solve it as a graph problem, where numbers 0, 1, ..., n are vertices, which connected like: 0-1, 1-2, ... |

Test4 | Nadezhda | 1134. Cards | 7 Oct 2020 20:45 | 5 |

Test4 **Nadezhda** 9 Nov 2013 17:52 Please, tell me what is in Test4??????? I also got WA for test 4.....so I started to try some self made test cases.....and I came across this one : 5 4 2 0 1 3 My output : NO. Correct Output should be YES. I will have to rethink my approach.....maybe you have the same problem as well. case 3 3 1 2 3 helped me in test 4. But anyway it's better to write your own test case generator.
*Edited by author 18.04.2020 04:47* |

WA3 test | Gleb | 1134. Cards | 7 May 2020 16:35 | 2 |

Some useful tests for WA3: 3 3 2 2 3 answer: NO 4 3 2 2 3 answer: YES No these won't help for WA at 3. |

Numbers might me separated by LINE FEEDS | Mahilewets | 1134. Cards | 24 Jun 2017 15:07 | 1 |

Pay attention. You might have WA12 just because you don't assume numbers might be separated by LINE FEEDS. |

Help requested | Erast V. Kunenkov | 1134. Cards | 8 Nov 2016 17:36 | 11 |

Here is my solution and used test cases. I don't understand why I always get WA. 8-( Test 1. 5 4 2 0 1 2: NO Test 2.5 4 2 0 1 5: YES Test 3. 5 4 2 0 3 5: YES Test 4. 5 4 2 0 3 4: YES Test 5. 5 5 2 0 3 4 5: YES Test 6. 5 5 2 0 2 4 5: YES Test 7. 5 6 2 1 2 4 5 0: NO Test 8. 5 4 1 2 2 3: YES Test 9. 5 5 1 2 3 4 3: YES Test 10. 5 5 1 1 0 3 4: NO Test 11. 5 3 0 0 1: NO Test 12. 5 3 0 1 1: NO Test 13. 5 3 1 2 2: YES Test 14. 5 3 1 1 2: YES Test 15. 5 3 4 4 5: NO Test 16. 5 3 3 4 4: YES Test 17. 5 3 4 5 5: NO Test 18. 5 3 3 4 5: YES Test 19. 2 2 1 1: YES Test 20. 2 2 2 2: NO Source code: [code deleted]
*Edited by moderator 13.02.2007 20:57* If the num of cards is lower than m i think that the asnwer should be NO 2.5 4 2 0 1 5 YES?
*Edited by author 19.01.2007 12:34* I'm not very good in C, and i don't undrstand your source) But my idea is very simple. Store in array number of repeats, increment a[0] and a[n] (because it's only one card with this numbers) and find in array sequence 2 1 1 .. 1 1 2 that's all)
*Edited by author 22.04.2009 22:45* i think so.i think that test#9 may be wrong.or i made mistake while reading the problem... tell the truth,i don't really understand the problem .. I don't understand Test 5. 5 5 2 0 3 4 5: YES Why? first 5 so take 5 or 6 second 5 so take 5 or 6 so take 5 and 6 ... last 5 so take 5 or 6 again, but 5 and 6 were taken, so NO help me, please for the 1st and the 2nd 5 means n and m without meaning the number which was took. here are test right
*Edited by author 31.12.2012 02:08*
*Edited by author 31.12.2012 02:08*
*Edited by author 31.12.2012 02:08* |

Why I get WA? Pelase, help me!!!!!!! | Revenger and NSC | 1134. Cards | 7 Nov 2016 17:55 | 4 |

There is my code: Program t1134; Const MaxN=1000; Var Card : array[1..MaxN]of boolean; Numb : array[1..MaxN]of integer; Use : array[1..MaxN]of boolean; M,N,i,j : integer; ex : boolean; begin Read(N,M); if (M>N)or(m=0) then begin writeln('NO'); halt(0); end; for i:=1 to N do Card[i]:=false; for i:=1 to M do Use[i]:=false; for i:=1 to M do begin read(Numb[i]); if (Numb[i]<0)or(Numb[i]>n) then begin writeln('NO'); halt(0); end; end; for i:=1 to M do if Numb[i]=0 then begin Use[i]:=true; if Card[1] then begin writeln('NO'); halt(0); end; Card[1]:=true; end else if Numb[i]=n then begin Use[i]:=true; if Card[n] then begin writeln('NO'); halt(0); end; Card[n]:=true; end; for i:=1 to m-1 do if not(use[i]) then for j:=i+1 to m do if not(use[j]) then if numb[i]=numb[j] then begin if (card[numb[i]])or(card[numb[j]-1]) then begin writeln('NO'); halt(0); end; card[numb[i]-1]:=true; card[numb[i]]:=true; use[i]:=true; use[j]:=true; end; repeat ex:=true; for i:=1 to m do if not(use[i]) then if (card[numb[i]])or(card[numb[i]-1]) then begin if (card[numb[i]])and(card[numb[i]-1]) then begin writeln('NO'); halt(0); end; if card[numb[i]] then begin card[numb[i]-1]:=true; use[i]:=true; end else begin card[numb[i]-1]:=true; use[i]:=true; end; end; until ex; Writeln('YES'); end. 3 3 2 2 3 Maybe you forgot something, because the output of your program for this test case is 'YES'; hope this will help Good luck! > 3 3 > 2 2 3 > Maybe you forgot something, because the output of your program for > this test case is 'YES'; > hope this will help > Good luck! > i suppose the answer should be NO for that 2 2 means the 2nd and the 3rd had been taken, so the third number 3 is uncorrect 3 3 2 2 3 Maybe you forgot something, because the output of your program for this test case is 'YES'; hope this will help Good luck! |

Test 3 | ionkinssau6107 | 1134. Cards | 26 Dec 2015 23:54 | 1 |

Test 3 **ionkinssau6107** 26 Dec 2015 23:54 Sorry for my bad english I'm see all exists tests, and I'm get a correct result on these tests(according comments). Let <ms> is init array, <flag> is (answer is YES?). 1. I do check that (the number in <ms>) is not greater than <n> 2. I'm sorted <ms>. 3. I'm create a <isFills> = new Array[Boolean](n+1) And then I use the following code: if (m>1 && ms(1) == 0) return false // (ms(0)==ms(1)==0) => "NO" if (m>1 && ms(m-2)==n) return false // (ms(m-2)==ms(m-1)==n) => "NO"
isFills(max(ms(0)-1, 0)) = true for (i <- 1 until m) { if (!isFills(ms(i)-1) || !isFills(ms(i))) { if (!isFills(ms(i)-1)) isFills(ms(i)-1) = true else isFills(ms(i)) = true } else return false } return flag Console.println(if (getFlag==true) "YES" else "NO") Full code: object Main { import java.util.Scanner import math._
val scan = new Scanner(System.in) val n = scan.nextInt() val m = scan.nextInt() val ms = new Array[Int](max(m,1)) for (i <- 0 until m) ms(i) = scan.nextInt() scan.close()
def getFlag: Boolean = { var flag = true
for (i <- 0 until m) flag &&= ms(i)<=n if (!flag) return flag
java.util.Arrays.sort(ms) val isFills = new Array[Boolean](n+1)
if (m>1 && ms(1) == 0) return false if (m>1 && ms(m-2)==n) return false
isFills(max(ms(0)-1, 0)) = true for (i <- 1 until m) { if (!isFills(ms(i)-1) || !isFills(ms(i))) { if (!isFills(ms(i)-1)) isFills(ms(i)-1) = true else isFills(ms(i)) = true } else return false } flag } Console.println(if (getFlag==true) "YES" else "NO")
def main(args: Array[String]){} }
*Edited by author 26.12.2015 23:56*
*Edited by author 26.12.2015 23:57* |

Test 12 | Dusayarov Alisher | 1134. Cards | 28 Apr 2014 04:50 | 2 |

Test 12 **Dusayarov Alisher** 20 Mar 2013 14:11 Note that the numbers may be separated by spaces and newlines. |

Please explain test data 5 4 1 1 2 2 | Husan | 1134. Cards | 16 Apr 2014 21:01 | 4 |

please tell me how 1 1 2 2 can be YES.Because if Nick take cards for example that 0 1 reads 1 1 2 reads 1 2 3 reads 2 and he can't write 1 2 and 2 3 and answer must be NO i think Sorry I understnd all :)
*Edited by author 17.08.2008 04:31*
*Edited by author 17.08.2008 04:32* i don't understand why it can be YES
*Edited by author 22.04.2014 12:25* |

Hint | muhammad | 1134. Cards | 3 Jul 2012 17:30 | 2 |

Hint **muhammad** 16 May 2010 21:20 linear time input + O(nlogn) time sorting + O(n)time availability checking gives ac in .015 sec and 150 kb. I think better solution is possible. Please, let me know. Use Hash Sort which is O(n) |

test #5 | Flybird | 1134. Cards | 15 Jun 2011 16:44 | 3 |

i tryed all possible tests but i am still getting mistake on the fifth test. can somebody give me some tricky tests to help me? i have got this test too=( in this problem,sorting and greedy approach works.after sorting given card outcomes, we must iterate through these numbers and serve that card which has smallest possible number.using this,we make more chance to the next card to serve for the next outcome, i.e outcomes are ordered. |

C++ hint | ASK | 1134. Cards | 4 Nov 2010 13:51 | 1 |

The new compiler supports regex and thus the problem can be solved with 12 lines of real code (263 chars) and a 5-line header (include, ...). |

What's the answer for 2 2 1 1 and 2 2 2 2 ? | MadPsyentist/Sam | 1134. Cards | 7 Jun 2010 18:32 | 5 |

1. 2 2 1 1 - YES This is such a sequence: (1;2) and (1;0) 2. 2 2 2 2 - NO This is impossible because number 2 is written only on one card (2;1) so it couldn't appear twice. Good luck! > 1. 2 2 1 1 - YES > This is such a sequence: > (1;2) and (1;0) > 2. 2 2 2 2 - NO > This is impossible because number 2 is written only on one card (2;1) > so it couldn't appear twice. > > Good luck! > please tell me how 2 2 1 1 can be YES.Because if Nick take cards for example that 0 1 reads 1 1 2 reads 1 2 3 reads 2 and he can't write 1 2 and 2 3 and answer must be NO i think Here the first two numbers are N and M |

GREEDY! | Progress | 1134. Cards | 19 Aug 2009 09:32 | 2 |

I use n^4 algorythm and works for 0.015 secs. :P |

Mistake in statement | Fyodor Menshikov | 1134. Cards | 29 Apr 2009 02:45 | 2 |

m positive integer numbers are listed in sample there is number 0. So 'positive' should be replaced by 'non-negative'. |

May it help some. | Oleg Strekalovsky [Vologda SPU] | 1134. Cards | 22 Apr 2009 23:39 | 1 |

Remember, that (0,1) belong to the FIRST Card. If your get RE - check, that after Sorting every number < nCards =) |

How much mistakes Nick can do? | D_T_F | 1134. Cards | 5 Mar 2009 20:43 | 2 |

Subj. PS Im sorry for my english. Same in Russian: Сколько раз Ник может ошибиться? |

my code easy, pls help me!! | Bobur | 1134. Cards | 21 Apr 2008 21:32 | 1 |

var y : array [0..1001] of boolean; a : array [1..1001] of integer; i, m, n : integer; procedure quicksort; procedure sort(l, r : integer); var i1, j1, x, w : integer; begin i1 := l; j1 := r; x := a[(l+r) div 2]; repeat while a[i1]<x do inc(i1); while x<a[j1] do dec(j1); if i1 <= j1 then begin w := a[i1]; a[i1] := a[j1]; a[j1] := w; inc(i1); dec(j1); end; until i1 > j1; if l < j1 then sort(l, j1); if i1 < r then sort(i1, r); end; begin sort(1, m); end;{quicksort} begin fillchar(y, sizeOf(y), true); read(n, m); if n>= m then begin for i := 1 to m do read(a[i]); quicksort; y[0] := false; for i := 1 to m do if y[a[i]] then y[a[i]] := false else if y[a[i]+1] then y[a[i]+1] := false else begin writeLn('NO'); halt; end; writeLn('YES'); end else writeLn('NO'); end. i've WA#3, thanks. |

Some tests | Olzhas2dy | 1134. Cards | 9 Jun 2007 00:54 | 1 |

Ok, here are some: Test 1: 8 6 1 2 2 3 4 4 ANSWER: NO Test 2: 8 4 0 1 2 2 ANSWER: NO |

WA for test case #11 | shanky | 1134. Cards | 26 Mar 2007 02:12 | 1 |

My code works fine with the test cases discussed here ... But still am getting wrong answer for test case #11 Can anyone give a tricky test case tat would help me ?? |