# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
724515 | 2023-04-15T12:51:34 Z | TheSahib | Kutije (COCI21_kutije) | C++17 | 1000 ms | 18884 KB |
#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]; int dist[MAX][MAX]; bool visited[MAX]; void dfs(int node, int p){ visited[node] = 1; dist[p][node] = 1; for (int& to:g[node]) { if(!visited[to]){ 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++) { memset(visited, 0, sizeof(visited)); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 141 ms | 9112 KB | Output is correct |
2 | Correct | 119 ms | 8372 KB | Output is correct |
3 | Correct | 109 ms | 8140 KB | Output is correct |
4 | Correct | 135 ms | 9128 KB | Output is correct |
5 | Correct | 128 ms | 9024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1108 KB | Output is correct |
2 | Correct | 3 ms | 1108 KB | Output is correct |
3 | Correct | 3 ms | 980 KB | Output is correct |
4 | Correct | 3 ms | 1108 KB | Output is correct |
5 | Correct | 2 ms | 980 KB | Output is correct |
6 | Correct | 3 ms | 1108 KB | Output is correct |
7 | Correct | 4 ms | 1060 KB | Output is correct |
8 | Correct | 5 ms | 1108 KB | Output is correct |
9 | Correct | 3 ms | 1108 KB | Output is correct |
10 | Correct | 3 ms | 1108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1108 KB | Output is correct |
2 | Correct | 3 ms | 1108 KB | Output is correct |
3 | Correct | 3 ms | 980 KB | Output is correct |
4 | Correct | 3 ms | 1108 KB | Output is correct |
5 | Correct | 2 ms | 980 KB | Output is correct |
6 | Correct | 3 ms | 1108 KB | Output is correct |
7 | Correct | 4 ms | 1060 KB | Output is correct |
8 | Correct | 5 ms | 1108 KB | Output is correct |
9 | Correct | 3 ms | 1108 KB | Output is correct |
10 | Correct | 3 ms | 1108 KB | Output is correct |
11 | Correct | 3 ms | 1108 KB | Output is correct |
12 | Correct | 3 ms | 1108 KB | Output is correct |
13 | Correct | 4 ms | 1088 KB | Output is correct |
14 | Correct | 3 ms | 980 KB | Output is correct |
15 | Correct | 3 ms | 980 KB | Output is correct |
16 | Correct | 3 ms | 980 KB | Output is correct |
17 | Correct | 4 ms | 1108 KB | Output is correct |
18 | Correct | 3 ms | 1108 KB | Output is correct |
19 | Correct | 3 ms | 1108 KB | Output is correct |
20 | Correct | 3 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 141 ms | 9112 KB | Output is correct |
2 | Correct | 119 ms | 8372 KB | Output is correct |
3 | Correct | 109 ms | 8140 KB | Output is correct |
4 | Correct | 135 ms | 9128 KB | Output is correct |
5 | Correct | 128 ms | 9024 KB | Output is correct |
6 | Correct | 3 ms | 1108 KB | Output is correct |
7 | Correct | 3 ms | 1108 KB | Output is correct |
8 | Correct | 3 ms | 980 KB | Output is correct |
9 | Correct | 3 ms | 1108 KB | Output is correct |
10 | Correct | 2 ms | 980 KB | Output is correct |
11 | Correct | 3 ms | 1108 KB | Output is correct |
12 | Correct | 4 ms | 1060 KB | Output is correct |
13 | Correct | 5 ms | 1108 KB | Output is correct |
14 | Correct | 3 ms | 1108 KB | Output is correct |
15 | Correct | 3 ms | 1108 KB | Output is correct |
16 | Correct | 3 ms | 1108 KB | Output is correct |
17 | Correct | 3 ms | 1108 KB | Output is correct |
18 | Correct | 4 ms | 1088 KB | Output is correct |
19 | Correct | 3 ms | 980 KB | Output is correct |
20 | Correct | 3 ms | 980 KB | Output is correct |
21 | Correct | 3 ms | 980 KB | Output is correct |
22 | Correct | 4 ms | 1108 KB | Output is correct |
23 | Correct | 3 ms | 1108 KB | Output is correct |
24 | Correct | 3 ms | 1108 KB | Output is correct |
25 | Correct | 3 ms | 1116 KB | Output is correct |
26 | Correct | 234 ms | 10060 KB | Output is correct |
27 | Correct | 203 ms | 9604 KB | Output is correct |
28 | Correct | 707 ms | 15384 KB | Output is correct |
29 | Correct | 432 ms | 18884 KB | Output is correct |
30 | Correct | 169 ms | 13944 KB | Output is correct |
31 | Correct | 159 ms | 15224 KB | Output is correct |
32 | Execution timed out | 1082 ms | 16128 KB | Time limit exceeded |
33 | Halted | 0 ms | 0 KB | - |