Submission #669371

# Submission time Handle Problem Language Result Execution time Memory
669371 2022-12-06T10:14:32 Z ShaShi Pipes (CEOI15_pipes) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define lint long long int
#define dint long double
#define ll long long
#define endl "\n"
#define pii pair<int, int>
#define pb push_back
#define F first
#define S second

using namespace std;

const int MOD = (int)1e9 + 23;
const int MAXN = (int)1e5 + 23;
const int MAX_LOG = 17 + 1;
const int INF = (int)1e9 + 23;

int n, m, tmp, tmp2, u, v;
int par1[MAXN], par2[MAXN], sz1[MAXN], sz2[MAXN], h[MAXN], dp[MAXN], seen[MAXN];
vector<int> adj[MAXN];


void get_par1(int v) {
    return (par1[v] == -1? v : par1[v] = get_par1(par1[v]));
}

void get_par2(int v) {
    return (par2[v] == -1? v : par2[v] = get_par2(par2[v]));
}

bool merge1(int u, int v) {
    u = get_par1(u);
    v = get_par1(v);

    if (u == v) return 0;

    par1[u] = v;

    return 1;
}

bool merge2(int u, int v) {
    u = get_par2(u);
    v = get_par2(v);

    if (u == v) return 0;

    par2[u] = v;

    return 1;
}

void DFS(int v, int par){
	dp[v] = h[v];
	seen[v] = 1;


	for(int u:adj[v]) {
		if(!seen[u]) {
			h[u] = h[v]+1;
			DFS(u,v);
			dp[v] = min(dp[v], dp[u]);
		} else if(u!=par){
			dp[v] = min(dp[v], h[u]);
		}
	}

	if (par!=-1 && dp[v]==h[v]){
		cout << par << " " << v << endl;
	}
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;

    fill(par1, par1+n+1, -1);
    fill(par2, par2+n+1, -1);

    for (int i=1; i<=m; i++) {
        cin >> u >> v;

        if (merge1(u, v) || merge2(u, v)) {
            adj[u].pb(v);
            adj[v].pb(u);
        }
    }

    for (int i=1; i<=n; i++) {
        if (!seen[i]) {
            DFS(i, -1);
        }
    }

    
    


    return 0;
}

Compilation message

pipes.cpp: In function 'void get_par1(int)':
pipes.cpp:24:50: error: void value not ignored as it ought to be
   24 |     return (par1[v] == -1? v : par1[v] = get_par1(par1[v]));
      |                                          ~~~~~~~~^~~~~~~~~
pipes.cpp: In function 'void get_par2(int)':
pipes.cpp:28:50: error: void value not ignored as it ought to be
   28 |     return (par2[v] == -1? v : par2[v] = get_par2(par2[v]));
      |                                          ~~~~~~~~^~~~~~~~~
pipes.cpp: In function 'bool merge1(int, int)':
pipes.cpp:32:17: error: void value not ignored as it ought to be
   32 |     u = get_par1(u);
      |         ~~~~~~~~^~~
pipes.cpp:33:17: error: void value not ignored as it ought to be
   33 |     v = get_par1(v);
      |         ~~~~~~~~^~~
pipes.cpp: In function 'bool merge2(int, int)':
pipes.cpp:43:17: error: void value not ignored as it ought to be
   43 |     u = get_par2(u);
      |         ~~~~~~~~^~~
pipes.cpp:44:17: error: void value not ignored as it ought to be
   44 |     v = get_par2(v);
      |         ~~~~~~~~^~~