This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |