Submission #658180

# Submission time Handle Problem Language Result Execution time Memory
658180 2022-11-12T10:48:04 Z blaze21 Pipes (CEOI15_pipes) C++17
Compilation error
0 ms 0 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <numeric>
#include <cassert>
#include <iomanip>
using namespace std;

#define pi pair<int, int>
#define f first
#define s second

vector <vector <int> > edges (1e5 + 5);
bool visited [1e5 + 5];
int tin [1e5 + 5], low [1e5 + 5];
int timer = 0;

void dfs(int v, int prev){

    visited[v] = true;
    tin[v] = low[v] = timer++;
    bool ok = false;

    for(int u : edges[v]){

        if(u == prev && !ok){

            ok = true;
            continue;
        }

        if(visited[u]){

            low[v] = min(low[v], tin[u]);
        }

        else{

            dfs(u, v);

            low[v] = min(low[v], low[u]);
        }
    }

    if(prev != -1 && tin[v] == low[v]){

        cout << prev << " " << v << endl;
    }
}

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, m;
    cin >> n >> m;

    vector <int> links1 (n + 1), links2 (n + 1), sz1 (n + 1, 1), sz2 (n + 1, 1);
    iota(links1.begin(), links1.end(), 0);
    iota(links2.begin(), links2.end(), 0);

    while(m--){

        int a, b, a1, b1, a2, b2;
        cin >> a >> b;
        a1 = a2 = a;
        b1 = b2 = b;

        while(a1 != links1[a1]){

            a1 = links1[a1];
        }

        while(b1 != links1[b1]){

            b1 = links1[b1];
        }

        while(a2 != links2[a2]){

            a2 = links2[a2];
        }

        while(b2 != links2[b2]){

            b2 = links2[b2];
        }

        if(a1 != b1){

            edges[a].push_back(b);
            edges[b].push_back(a);

            if(sz1[a1] < sz1[b1]){

                swap(a1, b1);
            }

            links1[b1] = a1;
            sz1[a1] += sz1[b1];
        }

        else if(a2 != b2){

            edges[a].push_back(b);
            edges[b].push_back(a);

            if(sz2[a2] < sz2[b2]){

                swap(a2, b2);
            }

            links2[b2] = a2;
            sz2[a2] += sz2[b2];
        }
    }

    for(int i = 1; i <= n; i++){

        if(!visited[i]){

            dfs(i, -1);
        }
    }
}

Compilation message

pipes.cpp:25:19: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   25 | bool visited [1e5 + 5];
      |               ~~~~^~~
pipes.cpp:25:19: error: could not convert '(1.0e+5 + (double)5)' from 'double' to 'long unsigned int'
pipes.cpp:25:19: error: size of array 'visited' has non-integral type 'double'
pipes.cpp:26:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   26 | int tin [1e5 + 5], low [1e5 + 5];
      |          ~~~~^~~
pipes.cpp:26:14: error: could not convert '(1.0e+5 + (double)5)' from 'double' to 'long unsigned int'
pipes.cpp:26:14: error: size of array 'tin' has non-integral type 'double'
pipes.cpp:26:29: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   26 | int tin [1e5 + 5], low [1e5 + 5];
      |                         ~~~~^~~
pipes.cpp:26:29: error: could not convert '(1.0e+5 + (double)5)' from 'double' to 'long unsigned int'
pipes.cpp:26:29: error: size of array 'low' has non-integral type 'double'