# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1237356 | atsoukalas | Kutije (COCI21_kutije) | C++20 | 1095 ms | 1392 KiB |
#include <bits/stdc++.h>
using namespace std;
vector<int> Adj[1005];
bool V[1005];
int main() {
int N, M, q;
scanf("%d%d%d", &N, &M, &q);
for(int i=0;i<M;++i){
for(int j=1;j<=N;++j){
int tmp; scanf("%d", &tmp);
bool exists=false;
for(int k=0;k<Adj[j].size();++k){
if(Adj[j][k]==tmp||j==tmp) exists = true;
}
if(!exists) Adj[j].push_back(tmp);
}
}
for(int i=0; i<q; ++i){
int S, G; scanf("%d%d", &S, &G);
queue<int> Q;
Q.push(S);
V[S] = true;
while(!Q.empty()){
int curr = Q.front(); Q.pop();
if(curr==G) {
V[G] = true;
break;
}
for(int j=0; j<Adj[curr].size();++j){
if(!V[Adj[curr][j]]){
Q.push(Adj[curr][j]);
V[Adj[curr][j]] = true;
}
}
}
if(V[G]) printf("DA\n");
else printf("NE\n");
fill(V, V+N+1, false);
}
return 0;
}
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... |