Submission #3768842


Source Code Expand

import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		boolean[] balls=new boolean[N];
		balls[0]=true;
		int[] ballvol=new int[N];
		for(int i=0; i<N; i++) {
			ballvol[i]=1;
		}
		for(int i=0; i<M; i++) {
			int s=sc.nextInt();
			int g=sc.nextInt();
			if(balls[s-1]) {
				if(ballvol[s-1]>1) {
					balls[g-1]=true;
					ballvol[s-1]--;
					ballvol[g-1]++;
					/*for(int j=0; j<N; j++) {
						System.out.print(ballvol[j]+" ");
					}*/
				}
				else if(ballvol[s-1]==1) {
					balls[s-1]=false;
					balls[g-1]=true;
					ballvol[s-1]--;
					ballvol[g-1]++;
					/*for(int j=0; j<N; j++) {
						System.out.print(ballvol[j]+" ");
					}*/
				}
			}
			else {
				ballvol[s-1]--;
				ballvol[g-1]++;
				/*for(int j=0; j<N; j++) {
					System.out.print(ballvol[j]+" ");
				}*/
			}
		}
		int count=0;
		for(int i=0; i<N; i++) {
			if(balls[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Submission Info

Submission Time
Task B - Box and Ball
User Digaus
Language Java8 (OpenJDK 1.8.0)
Score 400
Code Size 1071 Byte
Status AC
Exec Time 549 ms
Memory 66284 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 27
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt
Case Name Status Exec Time Memory
0_00.txt AC 96 ms 20692 KB
0_01.txt AC 94 ms 21844 KB
0_02.txt AC 95 ms 21844 KB
1_00.txt AC 94 ms 18640 KB
1_01.txt AC 95 ms 20816 KB
1_02.txt AC 98 ms 21076 KB
1_03.txt AC 96 ms 20564 KB
1_04.txt AC 495 ms 61120 KB
1_05.txt AC 498 ms 64060 KB
1_06.txt AC 549 ms 64008 KB
1_07.txt AC 515 ms 62656 KB
1_08.txt AC 450 ms 53912 KB
1_09.txt AC 463 ms 61744 KB
1_10.txt AC 291 ms 41268 KB
1_11.txt AC 383 ms 42808 KB
1_12.txt AC 169 ms 25648 KB
1_13.txt AC 500 ms 58548 KB
1_14.txt AC 389 ms 47916 KB
1_15.txt AC 497 ms 60268 KB
1_16.txt AC 149 ms 25832 KB
1_17.txt AC 534 ms 66284 KB
1_18.txt AC 497 ms 65796 KB
1_19.txt AC 524 ms 63312 KB
1_20.txt AC 522 ms 64624 KB
1_21.txt AC 473 ms 63164 KB
1_22.txt AC 533 ms 62064 KB
1_23.txt AC 333 ms 47052 KB