# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1237330 | atsoukalas | Kutije (COCI21_kutije) | C++20 | 1096 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;
}
컴파일 시 표준 에러 (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... |