Submission #580249

# Submission time Handle Problem Language Result Execution time Memory
580249 2022-06-20T19:38:49 Z MODDI Pipes (CEOI15_pipes) C++14
10 / 100
1825 ms 65536 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n, m;
vector<int> G[100010];
vector<bool> vis;
vi tin, low;
int timer;
vector<pii> ans;
bool out[100][100];
void dfs(int node, int parent = -1){
	vis[node] = true;
	tin[node] = low[node] = timer++;
	for(auto next : G[node]){
		if(next == parent)	continue;
		if(vis[next]){
			low[node] = min(low[node], tin[next]);
		}
		else{
			dfs(next, node);
			low[node] = min(low[node], low[next]);
			if(low[next] > tin[node]){
				ans.pb(mp(node,next));
			}
		}
	}
}
void init(){
	timer = 0;
	vis.assign(n, false);
	tin.assign(n, -1);
	low.assign(n, -1);
	for(int i = 0; i < n; i++){
		if(!vis[i])
			dfs(i);
	}
}
int main(){	
	memset(out, false, sizeof(out));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	init();
	for(int i = 0; i < (int)ans.size(); i++)
	{
		int a = ans[i].first, b = ans[i].second;
		if(!out[a][b] && !out[b][a]){
			cout<<a+1<<" "<<b+1<<endl;
			out[a][b] = true;
			out[b][a] = true;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Incorrect 1 ms 2644 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 116 ms 10856 KB Output is correct
2 Correct 107 ms 10216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 213 ms 14224 KB Output is correct
2 Runtime error 236 ms 29932 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 346 ms 25240 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 567 ms 31372 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 963 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1350 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1715 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1825 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -