답안 #38186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38186 2018-01-02T19:19:10 Z farmersrice Pipes (CEOI15_pipes) C++14
10 / 100
1093 ms 30708 KB
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#pragma GCC target ("avx,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside. AVX is better slightly
/*
TASK: hidden
LANG: C++11
*/
using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 70013
#define INF 1000000000000000000LL
#define mp make_pair
#define add push_back
#define remove pop

int n, m;
vector<int> adj[MAXN];
vector<pair2> answer;

int depth[MAXN], lowestAdjDepth[MAXN];

//returns subtree size
void solve(int current, int parent) {
	assert(depth[current] >= 1);
 
	lowestAdjDepth[current] = depth[current];
 
	int largestChildBCCsize = 0;
	for (int next : adj[current]) {
		if (next == parent) continue;
 
		if (lowestAdjDepth[next] >= 1) {
			lowestAdjDepth[current] = min(lowestAdjDepth[current], depth[next]);
		} else {
			//unvisited, let's go visit!
			depth[next] = depth[current] + 1;
 
			solve(next, current);
			lowestAdjDepth[current] = min(lowestAdjDepth[current], lowestAdjDepth[next]);
 
			if (lowestAdjDepth[next] > depth[current]) {
				//the next node is in a biconnected component unaffected by current node
				answer.add(mp(next, current));
			}
		}
	}
}

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;b--;

		adj[a].add(b);
		adj[b].add(a);
	}	

	for (int i = 0; i < n; i++) {
		if (depth[i] == 0) {
			depth[i] = 1;
			solve(i, -1);
		}
	}

	for (pair2 t : answer) {
		cout << t.first + 1 << ' ' << t.second + 1<< endl;
	}
}

Compilation message

pipes.cpp: In function 'void solve(int, int)':
pipes.cpp:33:6: warning: unused variable 'largestChildBCCsize' [-Wunused-variable]
  int largestChildBCCsize = 0;
      ^~~~~~~~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:56:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("FILENAME.in", "r", stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
pipes.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("FILENAME.out", "w", stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1920 KB Output is correct
2 Incorrect 3 ms 1920 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2560 KB Output is correct
2 Incorrect 6 ms 2304 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 10116 KB Output is correct
2 Correct 133 ms 9420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 13632 KB Output is correct
2 Runtime error 319 ms 18012 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 552 ms 24600 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1093 ms 30708 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 3848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -