답안 #948484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948484 2024-03-18T06:56:48 Z vjudge1 Pipes (CEOI15_pipes) C++17
10 / 100
606 ms 42060 KB
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (short)v.size()
 
//const short INF = 1e18;
//const short mod = 998244353;
const short N = 4005;

short n;
vector<pair<short,int> > adj[N];
vector<bool> visited(N);
vector<short> tin(N), low(N);
short timer;

void IS_BRIDGE(short u, short v){
	cout << u + 1 << ' ' << v + 1 << '\n';
}

void dfs(short v, int ind = -1) {
    visited[v] = true;
    tin[v] = low[v] = timer++;
    for (auto [to, nxt] : adj[v]) {
        if (nxt == ind) continue;
        if (visited[to]) {
            low[v] = min(low[v], tin[to]);
        } else {
            dfs(to, nxt);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v])
                IS_BRIDGE(v, to);
        }
    }
}

void find_bridges() {
    timer = 0;
    for (short i = 0; i < n; i++) {
        if (!visited[i])
            dfs(i);
    }
}

map<pair<short,short>, short> in;
void solve(){
	cin >> n;
	int m; cin >> m;
	for(int i = 0; i < m; i++){
		short u, v; cin >> u >> v;
		u--; v--;
		if(in[{min(u, v), max(u, v)}] == 2){
			
		}else{
			in[{min(u, v), max(u, v)}]++;
			adj[u].pb({v, i});
			adj[v].pb({u, i});
		}	
	}
	find_bridges();
}

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	short tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
}

Compilation message

pipes.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 606 ms 42060 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -