답안 #724604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724604 2023-04-15T16:05:48 Z TahirAliyev Kutije (COCI21_kutije) C++17
70 / 70
232 ms 11672 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;
int adj[MAX][MAX];
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; scanf("%d", &a);
            if(a == j) continue;
            adj[j][a] = 1;
        }
    }

    for (int i = 1; i < MAX; i++)
    {
        for (int j = 1; j < MAX; j++)
        {
            if(adj[i][j]){
                g[i].push_back(j);
            }
        }
        
    }
    
    for (int i = 1; i <= n; i++)
    {
        visited.reset();
        dfs(i, i);
    }
    
    
    while(q--){
        int a, b; scanf("%d%d", &a, &b);
        if(accesible[a][b]){
            cout << "DA\n";
        }
        else{
            cout << "NE\n";
        }
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:40:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |             int a; scanf("%d", &a);
      |                    ~~~~~^~~~~~~~~~
Main.cpp:65:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         int a, b; scanf("%d%d", &a, &b);
      |                   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 5244 KB Output is correct
2 Correct 89 ms 4940 KB Output is correct
3 Correct 87 ms 4644 KB Output is correct
4 Correct 108 ms 5300 KB Output is correct
5 Correct 104 ms 5196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 2 ms 596 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 3 ms 720 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 5244 KB Output is correct
2 Correct 89 ms 4940 KB Output is correct
3 Correct 87 ms 4644 KB Output is correct
4 Correct 108 ms 5300 KB Output is correct
5 Correct 104 ms 5196 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 3 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 3 ms 720 KB Output is correct
24 Correct 3 ms 724 KB Output is correct
25 Correct 3 ms 724 KB Output is correct
26 Correct 197 ms 6436 KB Output is correct
27 Correct 194 ms 5832 KB Output is correct
28 Correct 177 ms 9000 KB Output is correct
29 Correct 232 ms 7756 KB Output is correct
30 Correct 169 ms 3820 KB Output is correct
31 Correct 162 ms 5272 KB Output is correct
32 Correct 187 ms 11672 KB Output is correct
33 Correct 197 ms 8784 KB Output is correct
34 Correct 208 ms 9636 KB Output is correct
35 Correct 213 ms 9368 KB Output is correct