Submission #556873

#TimeUsernameProblemLanguageResultExecution timeMemory
556873new_accKutije (COCI21_kutije)C++14
70 / 70
173 ms9504 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e6+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e13; const ll mod2=998244353; const ll mod=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; int t[N],fau[N]; int Find(int a){ if(fau[a]==a) return a; return fau[a]=Find(fau[a]); } void Union(int a,int b){ a=Find(a),b=Find(b); fau[a]=b; } void solve(){ int n,m,q; cin>>n>>m>>q; for(int i=1;i<=n;i++) fau[i]=i; for(int i=1;i<=m;i++){ for(int k=1;k<=n;k++){ int a; cin>>a; Union(k,a); } } while(q--){ int a,b; cin>>a>>b; cout<<(Find(a)==Find(b)?"DA":"NE")<<"\n"; } } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); int tt=1; while(tt--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...