Submission #724517

#TimeUsernameProblemLanguageResultExecution timeMemory
724517TheSahibKutije (COCI21_kutije)C++17
70 / 70
210 ms13568 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define ll long long #define oo 1e9 + 9 #define pii pair<ll, ll> using namespace std; const int MAX = 1001; int n, m, q; int adj[MAX][MAX]; vector<int> g[MAX]; bitset<MAX> dist[MAX]; bitset<MAX> visited; void dfs(int node, int p){ visited[node] = 1; dist[p][node] = 1; for (int& to:g[node]) { if(!visited[to]){ if(to < p){ visited |= dist[to]; dist[p] |= dist[to]; continue; } dfs(to, p); } } } int main(){ cin >> n >> m >> q; for (int i = 0; i < m; i++) { for (int j = 1; j <= n; j++) { int a; scanf("%d", &a); if(j == a) continue; adj[j][a] = 1; } } for (int i = 1; i < MAX; i++) { for (int j = 1; j < MAX; j++) { if(adj[i][j]) g[i].push_back(j); } } for (int i = 1; i <= n; i++) { visited.reset(); dfs(i, i); } while(q--){ int a, b; scanf("%d%d", &a, &b); if(dist[a][b]){ cout << "DA\n"; } else{ cout << "NE\n"; } } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:42:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             int a; scanf("%d", &a);
      |                    ~~~~~^~~~~~~~~~
Main.cpp:61:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         int a, b; scanf("%d%d", &a, &b);
      |                   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...