Submission #724599

# Submission time Handle Problem Language Result Execution time Memory
724599 2023-04-15T15:57:24 Z TahirAliyev Kutije (COCI21_kutije) C++17
35 / 70
1000 ms 8248 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;
bitset<MAX> visited;
vector<int> g[MAX];

bitset<MAX> accesible[MAX];

void dfs(int node, int par){
    visited[node] = true;
    accesible[par][node] = true;
    for(int to : g[node]){
        if(!visited[to]){
            if(to < par){
                accesible[par] |= accesible[to];
                visited |= accesible[to];
                continue;
            }
            dfs(to, par);
        }
    }
}


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;
            if(a == j) continue;
            g[j].push_back(a);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        visited.reset();
        dfs(i, i);
    }
    
    
    while(q--){
        int a, b; cin >> a >> b;
        if(accesible[a][b]){
            cout << "DA\n";
        }
        else{
            cout << "NE\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 811 ms 2004 KB Output is correct
2 Correct 678 ms 1812 KB Output is correct
3 Correct 636 ms 1680 KB Output is correct
4 Correct 776 ms 2160 KB Output is correct
5 Correct 787 ms 1940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 3 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 3 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 356 KB Output is correct
17 Correct 3 ms 340 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 Correct 811 ms 2004 KB Output is correct
2 Correct 678 ms 1812 KB Output is correct
3 Correct 636 ms 1680 KB Output is correct
4 Correct 776 ms 2160 KB Output is correct
5 Correct 787 ms 1940 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 356 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 964 ms 5960 KB Output is correct
27 Correct 973 ms 6972 KB Output is correct
28 Correct 828 ms 7504 KB Output is correct
29 Correct 983 ms 6828 KB Output is correct
30 Correct 834 ms 4948 KB Output is correct
31 Correct 825 ms 6392 KB Output is correct
32 Execution timed out 1090 ms 8248 KB Time limit exceeded
33 Halted 0 ms 0 KB -