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 <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 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |