# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
720689 | Yell0 | Kutije (COCI21_kutije) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int MN=1002;
int n,m,q;
vector<int> adj[MN];
bool vis[MN];
ordered_set dest[MN];
void dfs(int u,int p) {
vis[u]=1;
dest[p].insert(u);
for(int v:adj[u])
if(!vis[v])
dfs(v,p);
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
cin>>n>>m>>q;
for(int i=1;i<=m;i++)
for(int u=1,v;u<=n;u++) {
cin>>v;
adj[v].push_back(u);
}
for(int i=1;i<=n;i++) {
memset(vis,0,sizeof(vis));
dfs(i,i);
}
int a,b;
while(q--) {
cin>>a>>b;
if(dest[a].count(b)) cout<<"DA\n";
else cout<<"NE\n";
}
return 0;
}