Submission #862373

#TimeUsernameProblemLanguageResultExecution timeMemory
862373TAhmed33Kutije (COCI21_kutije)C++98
70 / 70
831 ms10500 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast") using namespace std; bool adj[1001][1001]; int main () { ios::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { int x; cin >> x; adj[j][x] = 1; } } for (int i = 1; i <= n; i++) adj[i][i] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= n; k++) { adj[j][k] |= (adj[j][i] & adj[i][k]); } } } while (q--) { int a, b; cin >> a >> b; cout << (adj[a][b] ? "DA\n" : "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...