Submission #1108758

# Submission time Handle Problem Language Result Execution time Memory
1108758 2024-11-05T03:17:08 Z huantran Kutije (COCI21_kutije) C++17
70 / 70
221 ms 27464 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
const int maxn = 5e5 + 5;
const int oo = 1e9 + 7;
const ll inf = 1e18;

int n, m, q;
vector<int> adj[maxn];
int comp[maxn], cnt = 0;

void dfs(int u) {
    comp[u] = cnt;

    for (auto j : adj[u]) {
        if (comp[j])
            continue;
        dfs(j);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> n >> m >> q;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            int u;
            cin >> u;
            adj[u].push_back(j);
        }
    }

    for (int i = 1; i <= n; i++) {
        if (!comp[i]) {
            ++cnt;
            dfs(i);
        }
    }

    while (q--) {
        int u, v;
        cin >> u >> v;
        if (comp[u] == comp[v])
            cout << "DA" << '\n';
        else
            cout << "NE" << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 66 ms 19272 KB Output is correct
2 Correct 58 ms 18516 KB Output is correct
3 Correct 67 ms 18152 KB Output is correct
4 Correct 62 ms 19280 KB Output is correct
5 Correct 81 ms 19272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 13904 KB Output is correct
2 Correct 4 ms 13904 KB Output is correct
3 Correct 4 ms 14156 KB Output is correct
4 Correct 5 ms 13904 KB Output is correct
5 Correct 4 ms 14160 KB Output is correct
6 Correct 4 ms 13904 KB Output is correct
7 Correct 4 ms 13904 KB Output is correct
8 Correct 4 ms 13904 KB Output is correct
9 Correct 4 ms 13904 KB Output is correct
10 Correct 4 ms 13904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 13904 KB Output is correct
2 Correct 4 ms 13904 KB Output is correct
3 Correct 4 ms 14156 KB Output is correct
4 Correct 5 ms 13904 KB Output is correct
5 Correct 4 ms 14160 KB Output is correct
6 Correct 4 ms 13904 KB Output is correct
7 Correct 4 ms 13904 KB Output is correct
8 Correct 4 ms 13904 KB Output is correct
9 Correct 4 ms 13904 KB Output is correct
10 Correct 4 ms 13904 KB Output is correct
11 Correct 4 ms 13904 KB Output is correct
12 Correct 5 ms 14256 KB Output is correct
13 Correct 5 ms 13904 KB Output is correct
14 Correct 4 ms 13908 KB Output is correct
15 Correct 4 ms 13904 KB Output is correct
16 Correct 4 ms 14084 KB Output is correct
17 Correct 4 ms 13904 KB Output is correct
18 Correct 4 ms 13904 KB Output is correct
19 Correct 5 ms 13904 KB Output is correct
20 Correct 4 ms 13904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 19272 KB Output is correct
2 Correct 58 ms 18516 KB Output is correct
3 Correct 67 ms 18152 KB Output is correct
4 Correct 62 ms 19280 KB Output is correct
5 Correct 81 ms 19272 KB Output is correct
6 Correct 5 ms 13904 KB Output is correct
7 Correct 4 ms 13904 KB Output is correct
8 Correct 4 ms 14156 KB Output is correct
9 Correct 5 ms 13904 KB Output is correct
10 Correct 4 ms 14160 KB Output is correct
11 Correct 4 ms 13904 KB Output is correct
12 Correct 4 ms 13904 KB Output is correct
13 Correct 4 ms 13904 KB Output is correct
14 Correct 4 ms 13904 KB Output is correct
15 Correct 4 ms 13904 KB Output is correct
16 Correct 4 ms 13904 KB Output is correct
17 Correct 5 ms 14256 KB Output is correct
18 Correct 5 ms 13904 KB Output is correct
19 Correct 4 ms 13908 KB Output is correct
20 Correct 4 ms 13904 KB Output is correct
21 Correct 4 ms 14084 KB Output is correct
22 Correct 4 ms 13904 KB Output is correct
23 Correct 4 ms 13904 KB Output is correct
24 Correct 5 ms 13904 KB Output is correct
25 Correct 4 ms 13904 KB Output is correct
26 Correct 125 ms 27464 KB Output is correct
27 Correct 221 ms 27416 KB Output is correct
28 Correct 95 ms 25416 KB Output is correct
29 Correct 116 ms 27208 KB Output is correct
30 Correct 102 ms 25416 KB Output is correct
31 Correct 98 ms 25672 KB Output is correct
32 Correct 111 ms 27148 KB Output is correct
33 Correct 116 ms 26952 KB Output is correct
34 Correct 119 ms 26992 KB Output is correct
35 Correct 114 ms 27464 KB Output is correct