Submission #1463375


Source Code Expand

Copy
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean[] a = new boolean[N + 1];
		boolean[] b = new boolean[N + 1];
		for (int i = 0; i < M; i++) {
			int a_i = sc.nextInt();
			int b_i = sc.nextInt();

			if (a_i == 1) {
				a[b_i] = true;
			}
			if (b_i == 1) {
				a[a_i] = true;
			}
			if (a_i == N) {
				b[b_i] = true;
			}
			if (b_i == N) {
				b[a_i] = true;
			}
		}
		boolean answer = false;
		for (int i = 1; i <= N; i++) {
			if (a[i] && b[i]) {
				answer = true;
				break;
			}
		}
		if (answer) {
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User schwarzahl
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 854 Byte
Status
Exec Time 703 ms
Memory 94320 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0, example1, example2, example3
All 300 / 300 example0, example1, example2, example3, last0, last1, many0, many1, rand0, rand1, rand2
Case Name Status Exec Time Memory
example0 91 ms 20688 KB
example1 91 ms 19796 KB
example2 98 ms 17620 KB
example3 95 ms 20052 KB
last0 703 ms 92980 KB
last1 642 ms 92912 KB
many0 645 ms 94064 KB
many1 639 ms 94320 KB
rand0 569 ms 86920 KB
rand1 692 ms 93492 KB
rand2 579 ms 73028 KB