Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- set<int> lista;
- pair<int, int> pp;
- vector<pair<int, int>> v;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int n, m;
- cin >> n >> m;
- for(int i = 1; i <= n; i++) {
- lista.insert(i);
- }
- for(int i = 0; i < m; i++) {
- int a, b;
- cin >> a >> b;
- if(a > b) {
- v.push_back(make_pair(a, b));
- } else {
- v.push_back(make_pair(b, a));
- }
- }
- sort(v.begin(), v.end());
- reverse(v.begin(), v.end());
- for(auto itr : v) {
- if(lista.count(itr.first) == 1) {
- lista.erase(itr.second);
- }
- }
- cout << lista.size() << "\n";
- for(auto itr : lista) {
- cout << itr << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement