Submission #899593

#TimeUsernameProblemLanguageResultExecution timeMemory
899593duckindogKutije (COCI21_kutije)C++14
70 / 70
125 ms9556 KiB
// 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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...