Submission #1028820

# Submission time Handle Problem Language Result Execution time Memory
1028820 2024-07-20T09:11:30 Z atom Kutije (COCI21_kutije) C++17
70 / 70
886 ms 14680 KB
#include "bits/stdc++.h"
// @JASPER'S BOILERPLATE
using namespace std;
using ll = long long;

#ifdef JASPER
#include "debug.h"
#else
#define debug(...) 166
#endif

const int N = 1005;

vector <int> adj[N];
bool vis[N][N];

void dfs(int r, int u) {
    vis[r][u] = true;
    for (int v : adj[u]) {
        if (!vis[r][v]) {
            dfs(r, v);
        }
    }
}

signed main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    #ifdef JASPER
        freopen("in1", "r", stdin);
    #endif

    int n, m, q;
    cin >> n >> m >> q;

    for (int i = 1; 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) {
        sort(adj[i].begin(), adj[i].end());
        adj[i].resize(unique(adj[i].begin(), adj[i].end()) - adj[i].begin());
    }

    for (int i = 1; i <= n; ++i) {
        dfs(i, i);
    }

    for (int i = 1; i <= q; ++i) {
        int u, v;
        cin >> u >> v;
        debug(u, v);
        cout << (vis[u][v]? "DA" : "NE") << "\n";
    }
    
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:20: warning: statement has no effect [-Wunused-value]
    9 | #define debug(...) 166
      |                    ^~~
Main.cpp:55:9: note: in expansion of macro 'debug'
   55 |         debug(u, v);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 65 ms 6744 KB Output is correct
2 Correct 56 ms 6012 KB Output is correct
3 Correct 50 ms 5712 KB Output is correct
4 Correct 66 ms 6656 KB Output is correct
5 Correct 60 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 560 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 6744 KB Output is correct
2 Correct 56 ms 6012 KB Output is correct
3 Correct 50 ms 5712 KB Output is correct
4 Correct 66 ms 6656 KB Output is correct
5 Correct 60 ms 6736 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 560 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 147 ms 14420 KB Output is correct
27 Correct 123 ms 14632 KB Output is correct
28 Correct 496 ms 12624 KB Output is correct
29 Correct 323 ms 14160 KB Output is correct
30 Correct 94 ms 12624 KB Output is correct
31 Correct 114 ms 12564 KB Output is correct
32 Correct 886 ms 14680 KB Output is correct
33 Correct 114 ms 14396 KB Output is correct
34 Correct 110 ms 14416 KB Output is correct
35 Correct 116 ms 14508 KB Output is correct