답안 #724598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724598 2023-04-15T15:56:09 Z TahirAliyev Kutije (COCI21_kutije) C++17
35 / 70
1000 ms 6516 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;
set<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].insert(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";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 774 ms 2056 KB Output is correct
2 Correct 672 ms 1832 KB Output is correct
3 Correct 629 ms 1740 KB Output is correct
4 Correct 786 ms 2048 KB Output is correct
5 Correct 759 ms 2088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 774 ms 2056 KB Output is correct
2 Correct 672 ms 1832 KB Output is correct
3 Correct 629 ms 1740 KB Output is correct
4 Correct 786 ms 2048 KB Output is correct
5 Correct 759 ms 2088 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 3 ms 724 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 3 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 3 ms 596 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 4 ms 724 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Execution timed out 1052 ms 6516 KB Time limit exceeded
27 Halted 0 ms 0 KB -