import java.util.Scanner; /** * Created by Patrycja on 23.11.2016. */ public class reo { public static void main(String[] args) { int[] tab; Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); tab = new int[n]; for(int i = 0; i < m; i++) { in.nextInt(); int n2 = in.nextInt(); String yn = in.next(); if(yn.equals("N")) { tab[n2 - 1] = 1; } } int empl = -1; for(int i = 0; i < n; i++) { if(tab[i] == 0) { empl = i+1; break; } } if(empl == -1) System.out.println("NIE"); else { for(int i = 1; i <= n; i++) { if(i == empl) System.out.println(0); else System.out.println(empl); } } in.close(); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import java.util.Scanner; /** * Created by Patrycja on 23.11.2016. */ public class reo { public static void main(String[] args) { int[] tab; Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); tab = new int[n]; for(int i = 0; i < m; i++) { in.nextInt(); int n2 = in.nextInt(); String yn = in.next(); if(yn.equals("N")) { tab[n2 - 1] = 1; } } int empl = -1; for(int i = 0; i < n; i++) { if(tab[i] == 0) { empl = i+1; break; } } if(empl == -1) System.out.println("NIE"); else { for(int i = 1; i <= n; i++) { if(i == empl) System.out.println(0); else System.out.println(empl); } } in.close(); } } |