# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1058879 | 2024-08-14T14:41:10 Z | Thanhs | Kutije (COCI21_kutije) | C++14 | 117 ms | 9556 KB |
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long // #define double long double #define endl '\n' #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define setmin(x, y) x = min((x), (y)) #define setmax(x, y) x = max((x), (y)) #define sqr(x) ((x) * (x)) #define fi first #define se second #define all(x) x.begin(), x.end() // mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count()); // int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);} const int NM = 1e3 + 5; const int inf = 1e9; int p[NM], n, m, q; int find(int u) {return p[u] < 0 ? u : p[u] = find(p[u]);} void join(int u, int v) { u = find(u), v = find(v); if (u == v) return; if (p[u] > p[v]) swap(u, v); p[u] += p[v]; p[v] = u; } void solve() { memset(p, -1, sizeof p); cin >> n >> m >> q; while (m--) { for (int i = 1; i <= n; i++) { int j; cin >> j; join(i, j); } } while (q--) { int u, v; cin >> u >> v; cout << (find(u) == find(v) ? "DA" : "NE") << endl; } } signed main() { fastIO if (fopen("in.txt", "r")) { freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); } int tc = 1; // cin >> tc; while (tc--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 5716 KB | Output is correct |
2 | Correct | 41 ms | 4948 KB | Output is correct |
3 | Correct | 39 ms | 4692 KB | Output is correct |
4 | Correct | 46 ms | 5716 KB | Output is correct |
5 | Correct | 50 ms | 5608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 472 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 472 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 5716 KB | Output is correct |
2 | Correct | 41 ms | 4948 KB | Output is correct |
3 | Correct | 39 ms | 4692 KB | Output is correct |
4 | Correct | 46 ms | 5716 KB | Output is correct |
5 | Correct | 50 ms | 5608 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 472 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 492 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 85 ms | 9396 KB | Output is correct |
27 | Correct | 87 ms | 9556 KB | Output is correct |
28 | Correct | 69 ms | 7780 KB | Output is correct |
29 | Correct | 79 ms | 9044 KB | Output is correct |
30 | Correct | 75 ms | 8020 KB | Output is correct |
31 | Correct | 70 ms | 8020 KB | Output is correct |
32 | Correct | 77 ms | 9404 KB | Output is correct |
33 | Correct | 86 ms | 9556 KB | Output is correct |
34 | Correct | 79 ms | 9556 KB | Output is correct |
35 | Correct | 117 ms | 9556 KB | Output is correct |