Submission #534119

#TimeUsernameProblemLanguageResultExecution timeMemory
534119FashoKutije (COCI21_kutije)C++14
70 / 70
797 ms9404 KiB
#include <bits/stdc++.h> #define N 200005 #define ll long long int #define fo(i,x,y) for(int i=x;i<=y;i++) #define fs(ar,n) fo(i,1,n) cin>>ar[i] #define sp " " #define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) #define pb push_back #define ppb pop_back #define fi first #define se second #define ii pair<int,int> #define lli pair<ll,ll> #define fast2 freopen ("in.txt","r",stdin);freopen ("out.txt","w",stdout); #define mod 1000000007 using namespace std; ll n,m,ar[N],sum,t,dad[N],q; int find(int x) { if(dad[x]==x) return x; return dad[x]=find(dad[x]); } void unite(int x,int y) { dad[find(x)]=find(y); } int main() { fast; cin>>n>>m>>q; fo(i,1,n) dad[i]=i; for(int i=1;i<=m;i++) { for(int j=1;j<=n;j++) { int a; cin>>a; unite(j,a); } } for(int i=1;i<=q;i++) { int a,b; cin>>a>>b; if(find(a)==find(b)) cout<<"DA"<<endl; else cout<<"NE"<<endl; //cout<<find(a)<<sp<<find(b)<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...