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;
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 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... |