답안 #908191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908191 2024-01-16T09:19:46 Z IBory Conspiracy (POI11_kon) C++17
100 / 100
1321 ms 131072 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 5005;
bool G[MAX][MAX];
int out[MAX], no[MAX];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, ans = 0, E = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> out[i];
		E += out[i];
		for (int j = 0; j < out[i]; ++j) {
			int n;
			cin >> n;
			G[i][n] = 1;
		}
	}

	vector<int> S;
	int CN = N;
	while (CN > 1) {
		if (E == CN * (CN - 1)) break;
		int cand = 0, ec = 1e9;
		for (int i = 1; i <= N; ++i) {
			if (!no[i] && ec > out[i]) {
				ec = out[i];
				cand = i;
			}
		}
		E -= ec * 2;
		no[cand] = 1;
		S.push_back(cand);
		CN--;
	}

	// Init
	int temp = 1;
	for (int n1 : S) for (int n2 : S) if (G[n1][n2]) temp = 0;
	if (CN < N) ans += temp;

	// -1
	for (int i = 1; i <= N; ++i) {
		if (no[i]) continue;
		int ok = 1;
		for (int n : S) if (G[i][n]) ok = 0;
		if (ok && CN > 1) ans++;
	}

	// Replace
	for (int n1 : S) {
		int go = 0, r = 0;
		for (int i = 1; i <= N; ++i) {
			if (no[i]) continue;
			if (G[i][n1]) go++;
			else if (out[i]) r = i;
		}
		if (go != (N - S.size()) - 1) continue;
		int ok = 1;
		for (int n2 : S) {
			if (n1 == n2) continue;
			if (G[r][n2]) {
				ok = 0;
				break;
			}
		}
		if (ok) ans++;
	}

	cout << ans;
	return 0;
}

Compilation message

kon.cpp: In function 'int main()':
kon.cpp:60:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   if (go != (N - S.size()) - 1) continue;
      |       ~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2904 KB Output is correct
2 Correct 2 ms 2648 KB Output is correct
3 Correct 2 ms 2532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 3 ms 2652 KB Output is correct
3 Correct 2 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8924 KB Output is correct
2 Correct 38 ms 11432 KB Output is correct
3 Correct 160 ms 23780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 9052 KB Output is correct
2 Correct 54 ms 14420 KB Output is correct
3 Correct 203 ms 30544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 15700 KB Output is correct
2 Correct 123 ms 23648 KB Output is correct
3 Correct 333 ms 44044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 25712 KB Output is correct
2 Correct 260 ms 41412 KB Output is correct
3 Correct 778 ms 90196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 593 ms 72364 KB Output is correct
2 Correct 470 ms 55516 KB Output is correct
3 Correct 1222 ms 131072 KB Output is correct
4 Correct 1321 ms 131072 KB Output is correct
5 Correct 57 ms 580 KB Output is correct