Submission #464040

#TimeUsernameProblemLanguageResultExecution timeMemory
464040prvocisloUntitled (POI11_imp)C++17
90 / 100
1828 ms65540 KiB
#include <iostream> #include <vector> #include <set> using namespace std; const int maxn = 3005; int n, m; vector<vector<bool> > g(maxn, vector<bool>(maxn, false)); set<pair<int, int> > s; void rmv(int i) { for (int j = 0; j < n; j++) if (!g[i][j]) { if (s.count({ i,j })) s.erase({ i, j }); if (s.count({ j,i })) s.erase({ j, i }); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0, a, b; i < m; i++) { cin >> a >> b; a--, b--; g[a][b] = g[b][a] = true; } for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) if (!g[i][j]) s.insert({ i,j }); vector<bool> alive(n, true); while (!s.empty()) { int a = s.begin()->first, b = s.begin()->second; rmv(a), rmv(b); alive[a] = false, alive[b] = false; } vector<int> k; for (int i = 0; i < n; i++) if (alive[i]) k.push_back(i); for (int i = 0; i < n / 3; i++) cout << k[i] + 1 << " \n"[i == n / 3 - 1]; return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...