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>
using namespace std;
vector <int> adj[1001];
bool vis[1001][1001];
void dfs (int pos, int k) {
vis[pos][k] = 1;
for (auto j : adj[pos]) {
if (!vis[j][k]) {
dfs(j, k);
}
}
}
int main () {
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].push_back(x);
}
}
for (int i = 1; i <= n; i++) {
dfs(i, i);
}
while (q--) {
int a, b;
cin >> a >> b;
cout << (vis[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... |