Submission #854519

#TimeUsernameProblemLanguageResultExecution timeMemory
854519IBoryUntitled (POI11_kon)C++17
0 / 100
566 ms24944 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 5005; bool G[MAX][MAX]; int N, V[MAX], out[MAX], cnt; void Fail() { cout << 0; exit(0); } void DFS(int cur) { cnt++; for (int next = 1; next <= N; ++next) { if (V[next] || !G[cur][next]) continue; V[next] = 1; DFS(next); } } int main() { ios::sync_with_stdio(0); cin.tie(0); int 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; for (int j = 1; j < N; ++j) { if (E == (N - j + 1) * (N - j)) break; int cand = 0, ec = 1e9; for (int i = 1; i <= N; ++i) { if (ec > out[i]) { ec = out[i]; cand = i; } } for (int i = 1; i <= N; ++i) { if (!G[cand][i]) continue; if (!G[i][cand]) Fail(); out[i]--; G[cand][i] = 0; } out[cand] = 0; S.push_back(cand); E -= ec * 2; } // Init int temp = 1; for (int n1 : S) for (int n2 : S) if (G[n1][n2]) temp = 0; ans += temp; // -1 for (int i = 1; i <= N; ++i) { if (!out[i]) continue; int ok = 1; for (int n : S) { if (G[i][n]) { ok = 0; break; } } if (ok) ans++; } // Replace for (int n1 : S) { int go = 0, r = 0; for (int i = 1; i <= N; ++i) { 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)

kon.cpp: In function 'int main()':
kon.cpp:84:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   if (go != (N - S.size()) - 1) continue;
      |       ~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...