Submission #899593

# Submission time Handle Problem Language Result Execution time Memory
899593 2024-01-06T13:59:02 Z duckindog Kutije (COCI21_kutije) C++14
70 / 70
125 ms 9556 KB
// from duckindog wth depression
#include<bits/stdc++.h>

using namespace std;

const int N = 1e3 + 10;
int n, m, q;
int par[N];
int root(int u) {
  return (par[u] < 0 ? u : par[u] = root(par[u]));
}
void add(int u, int v) {
  u = root(u); v = root(v);
  if (u == v) return;
  if (par[u] >= par[v]) swap(u, v);
  par[u] += par[v];
  par[v] = u;
}

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  if (fopen("duck.inp", "r")) {
    freopen("duck.inp", "r", stdin);
    freopen("duck.out", "w", stdout);
  }
  memset(par, -1, sizeof par);
  cin >> n >> m >> q;

  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      int p; cin >> p;
      add(j, p);
    }
  }

  while(q--) {
    int x, y; cin >> x >> y;
    cout << (root(x) == root(y) ? "DA" : "NE") << '\n';
  }

}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:24:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     freopen("duck.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen("duck.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 66 ms 5576 KB Output is correct
2 Correct 59 ms 4944 KB Output is correct
3 Correct 53 ms 4552 KB Output is correct
4 Correct 64 ms 5712 KB Output is correct
5 Correct 69 ms 5712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 5576 KB Output is correct
2 Correct 59 ms 4944 KB Output is correct
3 Correct 53 ms 4552 KB Output is correct
4 Correct 64 ms 5712 KB Output is correct
5 Correct 69 ms 5712 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 2 ms 484 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 114 ms 9552 KB Output is correct
27 Correct 118 ms 9556 KB Output is correct
28 Correct 94 ms 7728 KB Output is correct
29 Correct 117 ms 9348 KB Output is correct
30 Correct 114 ms 8108 KB Output is correct
31 Correct 99 ms 8104 KB Output is correct
32 Correct 113 ms 9492 KB Output is correct
33 Correct 119 ms 9384 KB Output is correct
34 Correct 115 ms 9532 KB Output is correct
35 Correct 125 ms 9552 KB Output is correct