답안 #724597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724597 2023-04-15T15:45:51 Z TahirAliyev Kutije (COCI21_kutije) C++17
35 / 70
1000 ms 6488 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;
    accesible[node][par] = 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);
            g[a].insert(j);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        dfs(i, i);
        visited.reset();
    }
    
    
    while(q--){
        int a, b; cin >> a >> b;
        if(accesible[a][b]){
            cout << "DA\n";
        }
        else{
            cout << "NE\n";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 824 ms 2124 KB Output is correct
2 Correct 706 ms 2380 KB Output is correct
3 Correct 665 ms 2492 KB Output is correct
4 Correct 795 ms 2636 KB Output is correct
5 Correct 777 ms 2728 KB Output is correct
# 결과 실행 시간 메모리 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 3 ms 496 KB Output is correct
5 Correct 3 ms 368 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 4 ms 852 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 3 ms 496 KB Output is correct
5 Correct 3 ms 368 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 4 ms 852 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 4 ms 648 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 864 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 824 ms 2124 KB Output is correct
2 Correct 706 ms 2380 KB Output is correct
3 Correct 665 ms 2492 KB Output is correct
4 Correct 795 ms 2636 KB Output is correct
5 Correct 777 ms 2728 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 3 ms 340 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 3 ms 368 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 4 ms 852 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 648 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 5 ms 864 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Execution timed out 1012 ms 6488 KB Time limit exceeded
27 Halted 0 ms 0 KB -