답안 #509680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
509680 2022-01-14T08:08:33 Z KoD Kutije (COCI21_kutije) C++17
35 / 70
1000 ms 11108 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::pair;
using std::tuple;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, M, Q;
    std::cin >> N >> M >> Q;
    vector edge(N, vector<char>(N));
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < N; ++j) {
            int p;
            std::cin >> p;
            edge[p - 1][j] = true;
        }
    }
    vector reach(N, vector<char>(N));
    for (int src = 0; src < N; ++src) {
        std::queue<int> que;
        const auto push = [&](const int u) {
            if (!reach[src][u]) {
                reach[src][u] = true;
                que.push(u);
            }
        };
        push(src);
        while (!que.empty()) {
            const int u = que.front();
            que.pop();
            for (int i = 0; i < N; ++i) {
                if (edge[u][i]) {
                    push(i);
                }
            }
        }
    }
    while (Q--) {
        int a, b;
        std::cin >> a >> b;
        std::cout << (reach[a - 1][b - 1] ? "DA" : "NE") << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 670 ms 6660 KB Output is correct
2 Correct 568 ms 6564 KB Output is correct
3 Correct 246 ms 6248 KB Output is correct
4 Correct 822 ms 7480 KB Output is correct
5 Correct 92 ms 7492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 670 ms 6660 KB Output is correct
2 Correct 568 ms 6564 KB Output is correct
3 Correct 246 ms 6248 KB Output is correct
4 Correct 822 ms 7480 KB Output is correct
5 Correct 92 ms 7492 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 4 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 323 ms 11108 KB Output is correct
27 Correct 173 ms 11104 KB Output is correct
28 Execution timed out 1043 ms 5108 KB Time limit exceeded
29 Halted 0 ms 0 KB -