Submission #891528

#TimeUsernameProblemLanguageResultExecution timeMemory
891528Mr_PhKutije (COCI21_kutije)C++17
70 / 70
967 ms14592 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> typedef long long ll; using namespace std; using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>; const int mod=(int)1e9+7; ///the defines :) #define endl '\n' #define vi vector<int> #define vll vector<ll> #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i]; #define all(arr) arr.begin(),arr.end() #define allr(arr) arr.rbegin(),arr.rend() #define sz size() //#define int long long bool can[1002][1002]; vector<vi>adj; void dfs(int node,int toy) { //cout<<node<<" "<<toy<<endl; can[node][toy]=true; for(auto i:adj[node]) { if(!can[i][toy]){ //cout<<"WHAT"<<endl; dfs(i,toy); } } } void preprocess() {} void solve() { int n,m,q; cin>>n>>m>>q; adj.resize(n+1); for(int i=0;i<m;i++) { for(int j=1;j<=n;j++) { int x; cin>>x; adj[j].push_back(x); } } for(int i=1;i<=n;i++)dfs(i,i); while(q--) { int a,b; cin>>a>>b; if(can[b][a])cout<<"DA"<<endl; else cout<<"NE"<<endl; } } signed main() { // freopen("div7.in","r",stdin); //freopen("div7.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); preprocess(); //bla(); 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...