Submission #724558

# Submission time Handle Problem Language Result Execution time Memory
724558 2023-04-15T14:18:18 Z TahirAliyev Kutije (COCI21_kutije) C++17
35 / 70
1000 ms 7820 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 = 1005;
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 Correct 846 ms 4948 KB Output is correct
2 Correct 722 ms 4480 KB Output is correct
3 Correct 707 ms 3624 KB Output is correct
4 Correct 790 ms 5972 KB Output is correct
5 Correct 788 ms 3548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 4 ms 852 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 4 ms 980 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 4 ms 852 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 4 ms 980 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 4 ms 852 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 4 ms 980 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 846 ms 4948 KB Output is correct
2 Correct 722 ms 4480 KB Output is correct
3 Correct 707 ms 3624 KB Output is correct
4 Correct 790 ms 5972 KB Output is correct
5 Correct 788 ms 3548 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 4 ms 852 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 500 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 4 ms 852 KB Output is correct
19 Correct 4 ms 596 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 3 ms 468 KB Output is correct
22 Correct 4 ms 980 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 3 ms 468 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Execution timed out 1004 ms 7820 KB Time limit exceeded
27 Halted 0 ms 0 KB -