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;
bool us[1005][1005];
set<int>g[1005];
int m, n, q;
void dfs(int v, int st)
{
us[st][v] = 1;
for(auto to : g[v])
{
if(!us[st][to])
dfs(to, st);
}
}
void fun()
{
cin>>m>>n>>q;
for(int i = 1; i <= n; i++)
{
for(int j = 1, a; j <= m; j++)
{
cin>>a;
g[a].insert(j);
}
}
for(int i = 1; i <= m; i++)
{
dfs(i, i);
}
for(int i = 1, a, b; i <= q; i++)
{
cin>>a>>b;
cout<<((us[a][b]) ? "DA" : "NE")<<"\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ttt = 1;
//cin>>ttt;
while(ttt--)
fun();
}
# | 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... |