답안 #745684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745684 2023-05-21T01:55:33 Z rahulverma Kocka (COCI18_kocka) Java 11
70 / 70
785 ms 58120 KB
import java.util.*;
import java.io.*;

public class kocka {
    static final int N = 1_00_005, M = 2_010;
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int ok = 0;

        int[][] ans = new int[4][N];
        HashSet<Integer>[] st = new HashSet[N];

        for (int i = 0; i < N; i++) {
            st[i] = new HashSet<>();
        }
    	StringTokenizer ts = new StringTokenizer(br.readLine());
        for (int i = 1; i <= n; i++) {
            int x = Integer.parseInt(ts.nextToken());

            if (x == -1)
                x = n + 1;

            ans[0][i] = x + 1;
            st[x + 1].add(i);
        }
        ts = new StringTokenizer(br.readLine());
        for (int i = 1; i <= n; i++) {
            int x = Integer.parseInt(ts.nextToken());

            if (x == -1)
                x = n + 1;

            if (n - x != -1 && n - x < ans[0][i])
                ok = 1;

            ans[1][i] = n - x;

            if (n - x == -1)
                continue;

            st[n - x].add(i);
        }
        ts = new StringTokenizer(br.readLine());
        for (int i = 1; i <= n; i++) {
            int x = Integer.parseInt(ts.nextToken());

            if (x == -1)
                x = n + 1;

            if (st[i].size() == 0)
                continue;

            if (Collections.min(st[i]) <= x)
                ok = 1;

            ans[2][i] = x;
        }
        ts = new StringTokenizer(br.readLine());
        for (int i = 1; i <= n; i++) {
            int x = Integer.parseInt(ts.nextToken());

            if (x == -1)
                x = n + 1;

            if (st[i].size() == 0)
                continue;

            if (Collections.max(st[i]) > n - x)
                ok = 1;
        }
        PrintWriter pw = new PrintWriter(System.out);
        if (ok == 1)
            pw.println("NE");
        else
            pw.println("DA");

        pw.close();
    }
}


Compilation message

Note: kocka.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 20052 KB Output is correct
2 Correct 126 ms 17324 KB Output is correct
3 Correct 202 ms 19900 KB Output is correct
4 Correct 122 ms 17340 KB Output is correct
5 Correct 221 ms 19792 KB Output is correct
6 Correct 134 ms 17368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 19668 KB Output is correct
2 Correct 138 ms 16996 KB Output is correct
3 Correct 199 ms 19972 KB Output is correct
4 Correct 136 ms 17124 KB Output is correct
5 Correct 202 ms 19848 KB Output is correct
6 Correct 143 ms 17336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 671 ms 45520 KB Output is correct
2 Correct 749 ms 57764 KB Output is correct
3 Correct 697 ms 58084 KB Output is correct
4 Correct 457 ms 36420 KB Output is correct
5 Correct 740 ms 57992 KB Output is correct
6 Correct 773 ms 57968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 785 ms 52140 KB Output is correct
2 Correct 504 ms 36680 KB Output is correct
3 Correct 710 ms 58040 KB Output is correct
4 Correct 659 ms 43440 KB Output is correct
5 Correct 724 ms 56792 KB Output is correct
6 Correct 727 ms 54260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 644 ms 47272 KB Output is correct
2 Correct 470 ms 36664 KB Output is correct
3 Correct 711 ms 58120 KB Output is correct
4 Correct 683 ms 58000 KB Output is correct
5 Correct 756 ms 56872 KB Output is correct
6 Correct 495 ms 36628 KB Output is correct