#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;
#define maxn 500005
ll n,m;
vector<ll> g[maxn];
set<ll> s;
void tc(){
cin >> n >> m;
for(ll i = 1;i<=m;i++){
ll x,y; cin >> x >> y;
g[x].pb(y);
g[y].pb(x);
}
for(ll i = 1;i<=n;i++) s.insert(i);
vector<ll> ans;
while(si(s)){
ll x = *s.begin();
s.erase(s.begin());
ans.pb(x);
for(ll x : g[x]){
if(s.find(x)!=s.end()) s.erase(s.find(x));
}
}
cout<<si(ans)<<endl;
for(ll x : ans) cout<<x<<" ";
cout<<endl;
}
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
int t; t = 1;
while(t--){
tc();
}
return (0-0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
219 ms |
57572 KB |
Output is correct |
2 |
Correct |
215 ms |
57172 KB |
Output is correct |
3 |
Correct |
3 ms |
12124 KB |
Output is correct |
4 |
Correct |
120 ms |
37844 KB |
Output is correct |
5 |
Correct |
175 ms |
56152 KB |
Output is correct |
6 |
Correct |
192 ms |
55824 KB |
Output is correct |
7 |
Correct |
194 ms |
58928 KB |
Output is correct |
8 |
Correct |
181 ms |
55224 KB |
Output is correct |
9 |
Correct |
467 ms |
63892 KB |
Output is correct |
10 |
Correct |
400 ms |
59364 KB |
Output is correct |
11 |
Correct |
436 ms |
63392 KB |
Output is correct |
12 |
Correct |
487 ms |
59528 KB |
Output is correct |
13 |
Correct |
322 ms |
58196 KB |
Output is correct |
14 |
Correct |
293 ms |
58260 KB |
Output is correct |
15 |
Correct |
273 ms |
58544 KB |
Output is correct |
16 |
Correct |
255 ms |
58436 KB |
Output is correct |
17 |
Correct |
36 ms |
20308 KB |
Output is correct |
18 |
Correct |
55 ms |
24148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
225 ms |
57340 KB |
Output is correct |
2 |
Correct |
190 ms |
56684 KB |
Output is correct |
3 |
Correct |
182 ms |
56788 KB |
Output is correct |
4 |
Correct |
424 ms |
62216 KB |
Output is correct |
5 |
Correct |
529 ms |
64836 KB |
Output is correct |
6 |
Correct |
335 ms |
58452 KB |
Output is correct |
7 |
Correct |
303 ms |
58644 KB |
Output is correct |
8 |
Correct |
287 ms |
58452 KB |
Output is correct |
9 |
Correct |
261 ms |
58176 KB |
Output is correct |
10 |
Correct |
36 ms |
19796 KB |
Output is correct |
11 |
Correct |
38 ms |
19312 KB |
Output is correct |
12 |
Correct |
40 ms |
19540 KB |
Output is correct |
13 |
Correct |
212 ms |
55380 KB |
Output is correct |
14 |
Correct |
220 ms |
58196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
12636 KB |
Output is correct |
2 |
Correct |
4 ms |
12448 KB |
Output is correct |
3 |
Correct |
4 ms |
12636 KB |
Output is correct |
4 |
Correct |
5 ms |
12636 KB |
Output is correct |
5 |
Correct |
6 ms |
12636 KB |
Output is correct |
6 |
Correct |
5 ms |
12448 KB |
Output is correct |
7 |
Correct |
5 ms |
12636 KB |
Output is correct |
8 |
Correct |
4 ms |
12380 KB |
Output is correct |
9 |
Correct |
4 ms |
12124 KB |
Output is correct |
10 |
Correct |
3 ms |
12124 KB |
Output is correct |
11 |
Correct |
3 ms |
12124 KB |
Output is correct |
12 |
Correct |
4 ms |
12380 KB |
Output is correct |
13 |
Correct |
4 ms |
12380 KB |
Output is correct |
14 |
Correct |
3 ms |
12124 KB |
Output is correct |
15 |
Correct |
5 ms |
12636 KB |
Output is correct |
16 |
Correct |
6 ms |
12636 KB |
Output is correct |
17 |
Correct |
4 ms |
12636 KB |
Output is correct |
18 |
Correct |
3 ms |
12124 KB |
Output is correct |
19 |
Correct |
4 ms |
12380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
219 ms |
57572 KB |
Output is correct |
2 |
Correct |
215 ms |
57172 KB |
Output is correct |
3 |
Correct |
3 ms |
12124 KB |
Output is correct |
4 |
Correct |
120 ms |
37844 KB |
Output is correct |
5 |
Correct |
175 ms |
56152 KB |
Output is correct |
6 |
Correct |
192 ms |
55824 KB |
Output is correct |
7 |
Correct |
194 ms |
58928 KB |
Output is correct |
8 |
Correct |
181 ms |
55224 KB |
Output is correct |
9 |
Correct |
467 ms |
63892 KB |
Output is correct |
10 |
Correct |
400 ms |
59364 KB |
Output is correct |
11 |
Correct |
436 ms |
63392 KB |
Output is correct |
12 |
Correct |
487 ms |
59528 KB |
Output is correct |
13 |
Correct |
322 ms |
58196 KB |
Output is correct |
14 |
Correct |
293 ms |
58260 KB |
Output is correct |
15 |
Correct |
273 ms |
58544 KB |
Output is correct |
16 |
Correct |
255 ms |
58436 KB |
Output is correct |
17 |
Correct |
36 ms |
20308 KB |
Output is correct |
18 |
Correct |
55 ms |
24148 KB |
Output is correct |
19 |
Correct |
225 ms |
57340 KB |
Output is correct |
20 |
Correct |
190 ms |
56684 KB |
Output is correct |
21 |
Correct |
182 ms |
56788 KB |
Output is correct |
22 |
Correct |
424 ms |
62216 KB |
Output is correct |
23 |
Correct |
529 ms |
64836 KB |
Output is correct |
24 |
Correct |
335 ms |
58452 KB |
Output is correct |
25 |
Correct |
303 ms |
58644 KB |
Output is correct |
26 |
Correct |
287 ms |
58452 KB |
Output is correct |
27 |
Correct |
261 ms |
58176 KB |
Output is correct |
28 |
Correct |
36 ms |
19796 KB |
Output is correct |
29 |
Correct |
38 ms |
19312 KB |
Output is correct |
30 |
Correct |
40 ms |
19540 KB |
Output is correct |
31 |
Correct |
212 ms |
55380 KB |
Output is correct |
32 |
Correct |
220 ms |
58196 KB |
Output is correct |
33 |
Correct |
6 ms |
12636 KB |
Output is correct |
34 |
Correct |
4 ms |
12448 KB |
Output is correct |
35 |
Correct |
4 ms |
12636 KB |
Output is correct |
36 |
Correct |
5 ms |
12636 KB |
Output is correct |
37 |
Correct |
6 ms |
12636 KB |
Output is correct |
38 |
Correct |
5 ms |
12448 KB |
Output is correct |
39 |
Correct |
5 ms |
12636 KB |
Output is correct |
40 |
Correct |
4 ms |
12380 KB |
Output is correct |
41 |
Correct |
4 ms |
12124 KB |
Output is correct |
42 |
Correct |
3 ms |
12124 KB |
Output is correct |
43 |
Correct |
3 ms |
12124 KB |
Output is correct |
44 |
Correct |
4 ms |
12380 KB |
Output is correct |
45 |
Correct |
4 ms |
12380 KB |
Output is correct |
46 |
Correct |
3 ms |
12124 KB |
Output is correct |
47 |
Correct |
5 ms |
12636 KB |
Output is correct |
48 |
Correct |
6 ms |
12636 KB |
Output is correct |
49 |
Correct |
4 ms |
12636 KB |
Output is correct |
50 |
Correct |
3 ms |
12124 KB |
Output is correct |
51 |
Correct |
4 ms |
12380 KB |
Output is correct |
52 |
Correct |
216 ms |
57412 KB |
Output is correct |
53 |
Correct |
191 ms |
56556 KB |
Output is correct |
54 |
Correct |
182 ms |
56760 KB |
Output is correct |
55 |
Correct |
425 ms |
61888 KB |
Output is correct |
56 |
Correct |
519 ms |
64324 KB |
Output is correct |
57 |
Correct |
341 ms |
58340 KB |
Output is correct |
58 |
Correct |
298 ms |
58464 KB |
Output is correct |
59 |
Correct |
290 ms |
58556 KB |
Output is correct |
60 |
Correct |
39 ms |
20564 KB |
Output is correct |
61 |
Correct |
39 ms |
19796 KB |
Output is correct |
62 |
Correct |
39 ms |
19540 KB |
Output is correct |
63 |
Correct |
208 ms |
55632 KB |
Output is correct |
64 |
Correct |
215 ms |
56816 KB |
Output is correct |
65 |
Correct |
44 ms |
20128 KB |
Output is correct |
66 |
Correct |
574 ms |
61252 KB |
Output is correct |
67 |
Correct |
342 ms |
59232 KB |
Output is correct |
68 |
Correct |
296 ms |
58668 KB |
Output is correct |
69 |
Correct |
37 ms |
20356 KB |
Output is correct |
70 |
Correct |
109 ms |
36836 KB |
Output is correct |