Submission #851823

#TimeUsernameProblemLanguageResultExecution timeMemory
851823vjudge1Kutije (COCI21_kutije)C++17
70 / 70
131 ms2132 KiB
#ifndef Local #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #endif #include <bits/stdc++.h> #define int long long #define pb push_back #define lim 1000000 #define till 1000001 // # of primes till 1e6 = 7e4 using namespace std; using pii = array<int,2>; const int mod=1000000007ll; bitset<1000> v[1000]; bool vis[1000]; int n,m,q; void dfs(int i){ bool might=0; for(int j=0;j<n;j++){ if(v[i][j]&&!vis[j]){ vis[j]=1; if(((v[i])^(v[j]))!=0){ might=1; } v[i]|=v[j]; } } if(might)dfs(i); } void solve(){ cin>>n>>m>>q; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ v[i][j]=0; } } for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ int tem; cin>>tem; tem--; v[tem][j]=1; } } for(int i=0;i<n;i++){ memset(vis,0,n); dfs(i); } for(int i=0;i<n;i++){ v[i][i]=1; } while(q--){ int x,y; cin>>x>>y; x--,y--; if(v[x][y]==1){ cout<<"DA\n"; }else{ cout<<"NE\n"; } } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #endif int 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...