Submission #674508

# Submission time Handle Problem Language Result Execution time Memory
674508 2022-12-24T15:55:27 Z Farhan_HY Kutije (COCI21_kutije) C++14
70 / 70
150 ms 25544 KB
#include <bits/stdc++.h>
#define int long long
#define float double
#define pb push_back
#define F first
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
/// Benzema is the best player in the world
const int N = 1003;
int n, m, q, a[N][N], comp[N];
vector<int> adj[N];

void dfs(int node, int col) {
    comp[node] = col;
    for(auto x: adj[node])
        if (!comp[x])
            dfs(x, col);
}

main() {
    IOS
    cin >> n >> m >> q;
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= n; j++)
            cin >> a[i][j], adj[j].push_back(a[i][j]);
    }
    int col = 0;
    for(int i = 1; i <= n; i++) {
        if (comp[i] == 0)
            dfs(i, ++col);
    }
    while(q--) {
        int u, v;
        cin >> u >> v;
        if (comp[u] == comp[v]) cout << "DA\n";
        else cout << "NE\n";
    }
}

Compilation message

Main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 70 ms 5692 KB Output is correct
2 Correct 61 ms 5012 KB Output is correct
3 Correct 57 ms 4672 KB Output is correct
4 Correct 72 ms 5612 KB Output is correct
5 Correct 77 ms 5684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 912 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 1 ms 912 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 980 KB Output is correct
16 Correct 1 ms 876 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 5692 KB Output is correct
2 Correct 61 ms 5012 KB Output is correct
3 Correct 57 ms 4672 KB Output is correct
4 Correct 72 ms 5612 KB Output is correct
5 Correct 77 ms 5684 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 912 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 980 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 852 KB Output is correct
19 Correct 1 ms 852 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 876 KB Output is correct
22 Correct 1 ms 852 KB Output is correct
23 Correct 1 ms 980 KB Output is correct
24 Correct 1 ms 944 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 150 ms 25336 KB Output is correct
27 Correct 145 ms 25488 KB Output is correct
28 Correct 111 ms 22288 KB Output is correct
29 Correct 134 ms 24784 KB Output is correct
30 Correct 115 ms 23244 KB Output is correct
31 Correct 116 ms 23188 KB Output is correct
32 Correct 134 ms 25368 KB Output is correct
33 Correct 136 ms 25544 KB Output is correct
34 Correct 132 ms 25420 KB Output is correct
35 Correct 133 ms 25420 KB Output is correct