Submission #244499

# Submission time Handle Problem Language Result Execution time Memory
244499 2020-07-04T07:35:27 Z cheeheng Pipes (CEOI15_pipes) C++14
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <bitset>
using namespace std;

const int MAX_N = 30005;

vector<short> AdjList[MAX_N];

bitset<MAX_N> visited;

short dp[MAX_N];
short depth[MAX_N];

void dfs(short u, short p2, short d = 0){
    if(visited[u]){return;}
    depth[u] = d;
    visited[u] = true;
    dp[u] = 0;
    int cnt = 0;
    for(int v: AdjList[u]){
        if(!visited[v]){
            dfs(v, u, d+1);
            dp[u] += dp[v];
        }else if( (v != p2 || cnt >= 1) && depth[u] > depth[v]){
            // this is a back edge
            //printf("%d %d is a back edge\n", u, v);

            dp[u] ++;
            dp[v] --;
        }else if(v == p2){cnt ++;}
    }
    if(dp[u] == 0 && p2 != -1){
        printf("%d %d\n", u, p2);
    }
    //printf("dp[%d]=%d\n", u, dp[u]);
}

int main(){
    int N, M;
    scanf("%d%d", &N, &M);

    for(int i = 0; i < M; i ++){
        int a, b;
        scanf("%d%d", &a, &b);
        AdjList[a].push_back(b);
        AdjList[b].push_back(a);
    }

    //memset(dfs_low, -1, sizeof(dfs_low));
    //memset(dfs_num, -1, sizeof(dfs_num));
    //memset(p, -1, sizeof(p));
    int temp = 0;
    for(int i = 1; i <= N; i ++){
        if(!visited[i]){
            dfs(i, -1);
        }
    }

    /*for(int i = 1; i <= N; i ++){
        printf("%d %d\n", i, dp[i]);
    }*/

    return 0;
}

Compilation message

pipes.cpp:8:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector<short> AdjList[MAX_N];
 ^~~~~~
 wctob
pipes.cpp: In function 'void dfs(short int, short int, short int)':
pipes.cpp:21:16: error: 'AdjList' was not declared in this scope
     for(int v: AdjList[u]){
                ^~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:46:9: error: 'AdjList' was not declared in this scope
         AdjList[a].push_back(b);
         ^~~~~~~
pipes.cpp:53:9: warning: unused variable 'temp' [-Wunused-variable]
     int temp = 0;
         ^~~~
pipes.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
pipes.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~