Submission #1463427


Source Code Expand

Copy
import java.util.*;

public class Main {
    //-------------------------------------------------------------//
    public static final void main(String[] args) {
        new Main().solve();
    }
    //-------------------------------------------------------------//
    private final Scanner sc = new Scanner(System.in);

    void solve() {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        for (int i = 0; i < M; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean[] connected = new boolean[N + 1];
        for (int i = 0; i < M; i++) {
            if (b[i] == N) {
                connected[a[i]] = true;
            }
        }

        boolean check = false;
        for (int i = 0; i < M; i++) {
            if (connected[b[i]] && a[i] == 1) {
                check = true;
            }
        }

        if (check) System.out.println("POSSIBLE");
        else System.out.println("IMPOSSIBLE");
    }
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User suikkee
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 1072 Byte
Status AC
Exec Time 668 ms
Memory 97308 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 11
Set Name Test Cases
Sample example0, example1, example2, example3
All example0, example1, example2, example3, last0, last1, many0, many1, rand0, rand1, rand2
Case Name Status Exec Time Memory
example0 AC 137 ms 19028 KB
example1 AC 93 ms 21844 KB
example2 AC 94 ms 19668 KB
example3 AC 92 ms 23252 KB
last0 AC 668 ms 93056 KB
last1 AC 655 ms 96184 KB
many0 AC 644 ms 97308 KB
many1 AC 649 ms 93608 KB
rand0 AC 576 ms 90800 KB
rand1 AC 630 ms 95764 KB
rand2 AC 601 ms 74656 KB