Submission #1054340

# Submission time Handle Problem Language Result Execution time Memory
1054340 2024-08-12T08:54:13 Z vjudge1 Pipes (CEOI15_pipes) C++14
50 / 100
880 ms 65536 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sort undefined_function // To use stable_sort instead sort 
#define bpc __builtin_popcount
#define ull unsigned long long
#define ld double
#define ll long long
#define mp make_pair
#define F first
#define S second
 
using namespace std;

#define short unsigned short
 
vector<short> tin, low;
vector<vector<short>> g;
 
short timer = 0;
 
void dfs(short x, short prt = 0) {
	tin[x] = low[x] = ++timer;
	bool ok = 0;
 
	for (auto &y : g[x]) {
		if (y == prt && !ok) {
			ok = 1;
			continue;
		}
		
		if (tin[y] == 0) {
			dfs(y, x);
			low[x] = min(low[x], low[y]);
		} else {
			low[x] = min(low[x], tin[y]);
		}
 
		if (low[y] > tin[x])
			cout << x << " " << y << "\n";
	}
}
 
int32_t main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
 
	int n, m;
	cin >> n >> m;
 
	g.resize(n + 1);
	tin.resize(n + 1);
	low.resize(n + 1);
 
	for (int i = 1; i <= m; i ++) {
		int a, b;
		cin >> a >> b;
 
		g[a].push_back(b);
		g[b].push_back(a);
	}
 
	for (int i = 1; i <= n; i ++) {
		if (tin[i] == 0) 
			dfs(i);
	}
        
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 4692 KB Output is correct
2 Correct 54 ms 4176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 6660 KB Output is correct
2 Correct 114 ms 8788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 195 ms 13324 KB Output is correct
2 Correct 143 ms 11424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 233 ms 19028 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 442 ms 31660 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 563 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 698 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 880 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -