# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736838 | VadimK | Kutije (COCI21_kutije) | C++17 | 1032 ms | 13488 KiB |
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> g[1005];
int vis[1005];
void dfs (int v, int cmp)
{
vis[v]=cmp;
for (int i=0; i<g[v].size(); i++)
if (!vis[g[v][i]]) dfs(g[v][i],cmp);
}
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 v;
cin>>v;
g[j].push_back(v);
}
int cmp=1;
for (int i=1; i<=n; i++)
{
if (!vis[i]) dfs(i,cmp);
cmp++;
}
while (q--)
{
int a,b;
cin>>a>>b;
if (vis[a]==vis[b]) cout<<"DA";
else cout<<"NE";
cout<<"\n";
}
}
Compilation message (stderr)
# | 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... |