# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
908191 | IBory | Untitled (POI11_kon) | C++17 | 1321 ms | 131072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |