답안 #527217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527217 2022-02-17T03:52:11 Z siewjh Pipes (CEOI15_pipes) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 100'005;
vector<int> adjlist[MAXN];
int tvis[MAXN], lo[MAXN];
int cnt = 0;
vector<pair<int, int>> ans;
void dfs(int x, int par) {
	tvis[x] = lo[x] = cnt++;
	for (auto nxt : adjlist[x]) {
		if (nxt == par) continue;
		if (tvis[nxt] != INT_MAX) lo[x] = min(lo[x], tvis[nxt]);
		else {
			dfs(nxt, x);
			lo[x] = min(lo[x], lo[nxt]);
			if (lo[nxt] > tvis[x]) ans.push_back({ nxt, x });
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int nodes, edges; cin >> nodes >> edges;
	for (int i = 0; i < edges; i++) {
		int a, b; cin >> a >> b;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	for (int i = 1; i <= nodes; i++) tvis[i] = INT_MAX;
	for (int i = 1; i <= nodes; i++) 
		if (tvis[i] == INT_MAX)
			dfs(i, -1);
	for (auto x : ans) cout << x.first << ' ' << x.second << '\n';
	return 0;
}

Compilation message

pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:14:20: error: 'INT_MAX' was not declared in this scope
   14 |   if (tvis[nxt] != INT_MAX) lo[x] = min(lo[x], tvis[nxt]);
      |                    ^~~~~~~
pipes.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
pipes.cpp: In function 'int main()':
pipes.cpp:31:45: error: 'INT_MAX' was not declared in this scope
   31 |  for (int i = 1; i <= nodes; i++) tvis[i] = INT_MAX;
      |                                             ^~~~~~~
pipes.cpp:31:45: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
pipes.cpp:33:18: error: 'INT_MAX' was not declared in this scope
   33 |   if (tvis[i] == INT_MAX)
      |                  ^~~~~~~
pipes.cpp:33:18: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?