Submission #1022184

#TimeUsernameProblemLanguageResultExecution timeMemory
1022184vjudge1Kutije (COCI21_kutije)C++17
70 / 70
862 ms10064 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000 + 10; int n, m, q, reachable[N][N]; vector<int> g[N]; void dfs(int v, int s){ reachable[s][v] = 1; for (int u : g[v]) if (!reachable[s][u]) dfs(u, s); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> q; for (int j = 0; j < m; j ++){ for (int i = 1; i <= n; i ++){ int x; cin >> x; g[i].push_back(x); } } for (int v = 1; v <= n; v ++) dfs(v, v); for (int i = 0; i < q; i ++){ int u, v; cin >> u >> v; if (reachable[u][v]) cout << "DA\n"; else cout << "NE\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...