답안 #1035127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035127 2024-07-26T05:05:21 Z vjudge1 Pipes (CEOI15_pipes) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
using namespace std;
 
const int N = 1e5+2;
struct dsu {
	int e[N];
	void find(int &x) {
		 while(e[x]>=0) {
				 x=e[x];
			}
			//return x;
	}
	bool join(int a, int b) {
		a = find(a), b = find(b);
		if (a == b) return false;
		if (e[a] > e[b]) swap(a, b);
		e[a] += e[b]; e[b] = a;
		return true;
	}
} d1, d2;
vector<int> g[N];
int timer=0;
void dfs(int &at, int &par) {
	d1.e[at]=d2.e[at]=++timer;
	for(int &to:g[at]) {
		if(to == par) {
			par+=N;
			continue;
		}
		if(d2.e[to]) {
			d1.e[at]=min(d1.e[at], d2.e[to]);		
		} else {
			dfs(to, at);
			d1.e[at]=min(d1.e[at], d1.e[to]);
		}
	}
	if(par>N)par-=N;
	if(d1.e[at] == d2.e[at] and at!=par) {
		printf("%d %d\n", at, par);
	}
}
int n, m, u, v;
int main() {
	srand(time(0));
 
	scanf("%d %d", &n, &m);
	//nt u, v;
	for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=-1;
	for(int i = 0;i<m;i++) {
		scanf("%d %d", &u, &v);
		if((d1.join(u, v) || d2.join(u, v))) {
			g[u].push_back(v);
			g[v].push_back(u);
		}
	}
	for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=0;
	for(int i= 1;i<=n;i++) {
		if(!d1.e[i]) {
			dfs(i, i);
		}
	}
}

Compilation message

pipes.cpp: In member function 'bool dsu::join(int, int)':
pipes.cpp:15:11: error: void value not ignored as it ought to be
   15 |   a = find(a), b = find(b);
      |       ~~~~^~~
pipes.cpp:15:24: error: void value not ignored as it ought to be
   15 |   a = find(a), b = find(b);
      |                    ~~~~^~~
pipes.cpp: In function 'int main()':
pipes.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   scanf("%d %d", &u, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~