답안 #724602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724602 2023-04-15T16:03:30 Z TahirAliyev Kutije (COCI21_kutije) C++17
0 / 70
1 ms 468 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:28: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   40 |             int a; scanf("%d", a);
      |                           ~^   ~
      |                            |   |
      |                            |   int
      |                            int*
Main.cpp:65:27: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   65 |         int a, b; scanf("%d%d", a, b);
      |                          ~^     ~
      |                           |     |
      |                           int*  int
Main.cpp:65:29: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'int' [-Wformat=]
   65 |         int a, b; scanf("%d%d", a, b);
      |                            ~^      ~
      |                             |      |
      |                             int*   int
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);
      |                   ~~~~~^~~~~~~~~~~~~~
Main.cpp:40:17: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |             int a; scanf("%d", a);
      |                 ^
Main.cpp:65:13: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   65 |         int a, b; scanf("%d%d", a, b);
      |             ^
Main.cpp:66:26: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |         if(accesible[a][b]){
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -