제출 #504133

#제출 시각아이디문제언어결과실행 시간메모리
504133kojacKutije (COCI21_kutije)C++17
20 / 70
1084 ms3676 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 1020 #define INF 999999999 #define ll long long #define F first #define S second #define endl "\n" int n, m, q, lista[MAXN][MAXN]; bool foi[MAXN]; void dfs(int x){ for(int i = 1; i < MAXN; i++){ if(lista[x][i] == 1 && !foi[i]){ foi[i] = true; dfs(i); } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m >> q; for(int i = 0; i < m; i++){ for(int j = 1; j <= n; j++){ int x; cin >> x; lista[j][x] = 1; } } for(int i = 0; i < q; i++){ int a, b; for(int j = 0; j < MAXN; j++) foi[j] = false; cin >> a >> b; foi[a] = true; dfs(a); if(foi[b] || a == b) cout << "DA\n"; else cout << "NE\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...