Submission #724556

# Submission time Handle Problem Language Result Execution time Memory
724556 2023-04-15T14:17:38 Z TahirAliyev Kutije (COCI21_kutije) C++17
20 / 70
5 ms 852 KB
#include <bits/stdc++.h>

#pragma GCC optimize("O3")

using namespace std;
 
#define ll long long int
#define oo 1e18 + 5
#define pii pair<int, int>

const int MAX = 105;
bool visited[MAX];
set<int> g[MAX];

bool accessible[MAX][MAX];

void dfs(int node, vector<int> path){
    visited[node] = true;
    path.push_back(node);
    for(int a : path){
        accessible[a][node] = true;
        accessible[node][a] = true;
    }
    for(int to : g[node]){
        if(!visited[to]){
            dfs(to, path);
        }
    }
}


int main(){
    int n, m, q; cin >> n >> m >> q;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int a; cin >> a;
            g[j].insert(a);
            g[a].insert(j);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if(!visited[i]){
            dfs(i, vector<int>());
        }
    }
    while(q--){
        int a, b; cin >> a >> b;
        if(accessible[a][b]){
            cout << "DA\n";
        }
        else{
            cout << "NE\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 316 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 4 ms 572 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 4 ms 836 KB Output is correct
8 Correct 3 ms 340 KB Output is correct
9 Correct 3 ms 316 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 4 ms 572 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 4 ms 836 KB Output is correct
8 Correct 3 ms 340 KB Output is correct
9 Correct 3 ms 316 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 3 ms 324 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 5 ms 852 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 316 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -