답안 #724517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724517 2023-04-15T12:55:57 Z TheSahib Kutije (COCI21_kutije) C++17
70 / 70
210 ms 13568 KB
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
 
#define ll long long
#define oo 1e9 + 9
#define pii pair<ll, ll>
 
using namespace std;

const int MAX = 1001; 

int n, m, q;
int adj[MAX][MAX];
vector<int> g[MAX];
bitset<MAX> dist[MAX];

bitset<MAX> visited;
void dfs(int node, int p){
    visited[node] = 1;
    dist[p][node] = 1;
    for (int& to:g[node])
    {
        if(!visited[to]){
            if(to < p){
                visited |= dist[to];
                dist[p] |= dist[to];
                continue;
            }
            dfs(to, p);
        }
    }
}


int main(){
    cin >> n >> m >> q;
    for (int i = 0; i < m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int a; scanf("%d", &a);
            if(j == a) 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(dist[a][b]){
            cout << "DA\n";
        }
        else{
            cout << "NE\n";
        }
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:42:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             int a; scanf("%d", &a);
      |                    ~~~~~^~~~~~~~~~
Main.cpp:61:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         int a, b; scanf("%d%d", &a, &b);
      |                   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 5348 KB Output is correct
2 Correct 87 ms 4844 KB Output is correct
3 Correct 83 ms 4720 KB Output is correct
4 Correct 101 ms 5296 KB Output is correct
5 Correct 98 ms 5344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 3 ms 724 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 724 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 732 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 3 ms 724 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 724 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 732 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 5 ms 724 KB Output is correct
15 Correct 2 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 2 ms 724 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 104 ms 5348 KB Output is correct
2 Correct 87 ms 4844 KB Output is correct
3 Correct 83 ms 4720 KB Output is correct
4 Correct 101 ms 5296 KB Output is correct
5 Correct 98 ms 5344 KB Output is correct
6 Correct 3 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 724 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 732 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 3 ms 724 KB Output is correct
19 Correct 5 ms 724 KB Output is correct
20 Correct 2 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 2 ms 724 KB Output is correct
24 Correct 3 ms 724 KB Output is correct
25 Correct 3 ms 724 KB Output is correct
26 Correct 199 ms 6288 KB Output is correct
27 Correct 181 ms 5960 KB Output is correct
28 Correct 157 ms 8860 KB Output is correct
29 Correct 210 ms 7756 KB Output is correct
30 Correct 162 ms 3800 KB Output is correct
31 Correct 162 ms 5196 KB Output is correct
32 Correct 182 ms 13568 KB Output is correct
33 Correct 184 ms 12904 KB Output is correct
34 Correct 181 ms 13536 KB Output is correct
35 Correct 187 ms 13348 KB Output is correct