답안 #1042742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042742 2024-08-03T10:21:14 Z pawned 낙하산 고리들 (IOI12_rings) C++17
20 / 100
4000 ms 1052 KB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const int MAX = 5005;

int N;

vi adj[MAX];

void Init(int N_) {
	N = N_;
}

void Link(int A, int B) {
	adj[A].pb(B);
	adj[B].pb(A);
}

int CountCritical() {
	int total = 0;
	for (int i = 0; i < N; i++) {
		// try removing each vertex, make new adj
		// to check, ensure no adj cnt is >= 2
		// and N - edge_cnt equals number of ccs
		// removed link is a chain itself
		vi adjc[N];
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			if (j == i)
				continue;
			for (int k : adj[j]) {
				if (k != i) {
					adjc[j].pb(k);
					cnt++;
				}
			}
		}
		cnt /= 2;
		int maxc = 0;
		for (int j = 0; j < N; j++) {
			maxc = max(maxc, (int)(adjc[j].size()));
		}
//		cout<<"cnt, maxc: "<<cnt<<" "<<maxc<<endl;
		int ccs = 0;
		vector<bool> vis(N, false);
		for (int j = 0; j < N; j++) {
			if (!vis[j]) {
				ccs++;
				queue<int> q;
				q.push(j);
				vis[j] = true;
				while (!q.empty()) {
					int x = q.front();
					q.pop();
					for (int y : adjc[x]) {
						if (!vis[y]) {
							q.push(y);
							vis[y] = true;
						}
					}
				}
			}
		}
//		cout<<"ccs: "<<ccs<<endl;
		if ((maxc <= 2) && (N - cnt == ccs))
			total++;
	}
	return total;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 874 ms 860 KB Output is correct
3 Correct 1196 ms 856 KB Output is correct
4 Correct 43 ms 600 KB Output is correct
5 Correct 400 ms 600 KB Output is correct
6 Correct 1267 ms 1052 KB Output is correct
7 Correct 715 ms 716 KB Output is correct
8 Correct 783 ms 932 KB Output is correct
9 Correct 1191 ms 1040 KB Output is correct
10 Correct 1212 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 874 ms 860 KB Output is correct
3 Correct 1196 ms 856 KB Output is correct
4 Correct 43 ms 600 KB Output is correct
5 Correct 400 ms 600 KB Output is correct
6 Correct 1267 ms 1052 KB Output is correct
7 Correct 715 ms 716 KB Output is correct
8 Correct 783 ms 932 KB Output is correct
9 Correct 1191 ms 1040 KB Output is correct
10 Correct 1212 ms 856 KB Output is correct
11 Execution timed out 4038 ms 604 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 874 ms 860 KB Output is correct
3 Correct 1196 ms 856 KB Output is correct
4 Correct 43 ms 600 KB Output is correct
5 Correct 400 ms 600 KB Output is correct
6 Correct 1267 ms 1052 KB Output is correct
7 Correct 715 ms 716 KB Output is correct
8 Correct 783 ms 932 KB Output is correct
9 Correct 1191 ms 1040 KB Output is correct
10 Correct 1212 ms 856 KB Output is correct
11 Execution timed out 4038 ms 604 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 874 ms 860 KB Output is correct
3 Correct 1196 ms 856 KB Output is correct
4 Correct 43 ms 600 KB Output is correct
5 Correct 400 ms 600 KB Output is correct
6 Correct 1267 ms 1052 KB Output is correct
7 Correct 715 ms 716 KB Output is correct
8 Correct 783 ms 932 KB Output is correct
9 Correct 1191 ms 1040 KB Output is correct
10 Correct 1212 ms 856 KB Output is correct
11 Runtime error 1 ms 856 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -