Submission #851819

#TimeUsernameProblemLanguageResultExecution timeMemory
851819vjudge1Kutije (COCI21_kutije)C++17
70 / 70
124 ms2188 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define endl "\n" #define all(x) x.begin(), x.end() #define ll long long #define int long long #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define inf 1000000009 #define MOD 998244353 using namespace std; int dad[1005]; 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); } void solve(){ int n,m,q; cin >> n >> m >> q; for(int i=1; i<=n; i++) dad[i]=i; for(int i=1; i<=m; i++){ for(int j=1; j<=n; j++){ int a; cin >> a; unite(a, j); } } while(q--){ int a,b; cin >> a >> b; if(find(a)==find(b)) cout << "DA" << endl; else cout << "NE" << endl; } } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #endif ll t=1; //cin >> t; while(t--) 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...