#include <bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
int n,m;
vector<int>v[3005];
bitset<3005>curr,mat[3005],vis;
int cnt=0;
void rec(int x){
if(cnt==n/3){
for(int i=0;i<3005;i++){
if(curr[i]==1) co i<<' ';
}
exit(0);
}
if(x==n) return;
if(n-x+cnt<n/3) return ;
if((curr&mat[x])==curr){
curr[x]=1;
cnt++;
rec(x+1);
cnt--;
curr[x]=0;
}
rec(x+1);
return;
}
void rec1(ll x,ll last){
if(x==n/3){
for(int i=0;i<3005;i++){
if(curr[i]==1) co i<<' ';
}
exit(0);
}
ll num;
bitset<3005>dont={};
if(last==-1){
num=rand()%n+1;
while(dont[num]||vis[num]||(curr&mat[num])!=curr) dont[num]=1,num=rand()%n+1;
}
else{
num=v[last][rand()%v[last].size()];
while(dont[num]||vis[num]||(curr&mat[num])!=curr) dont[num]=1,num=v[last][rand()%v[last].size()];
}
vis[num]=1;
curr[num]=1;
rec1(x+1,num);
curr[num]=0;
vis[num]=0;
}
void solve(){
cin>>n>>m;
for(int i=0;i<m;i++){
ll a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
mat[a][b]=1;
mat[b][a]=1;
}
if(n<=100) rec(0);
else while(1) rec1(0,-1);
}
int main()
{
suiii
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3040 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1372 KB |
Output is correct |
2 |
Correct |
44 ms |
5460 KB |
Output is correct |
3 |
Correct |
34 ms |
5456 KB |
Output is correct |
4 |
Correct |
35 ms |
5460 KB |
Output is correct |
5 |
Execution timed out |
3045 ms |
5456 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
1880 KB |
Output is correct |
2 |
Correct |
88 ms |
12564 KB |
Output is correct |
3 |
Correct |
94 ms |
12372 KB |
Output is correct |
4 |
Correct |
88 ms |
12368 KB |
Output is correct |
5 |
Correct |
90 ms |
12532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
4444 KB |
Output is correct |
2 |
Correct |
130 ms |
17492 KB |
Output is correct |
3 |
Correct |
126 ms |
17488 KB |
Output is correct |
4 |
Execution timed out |
3048 ms |
16980 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
77 ms |
12628 KB |
Output is correct |
2 |
Correct |
160 ms |
19260 KB |
Output is correct |
3 |
Execution timed out |
3043 ms |
19116 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
151 ms |
16696 KB |
Output is correct |
2 |
Correct |
226 ms |
22172 KB |
Output is correct |
3 |
Correct |
224 ms |
22096 KB |
Output is correct |
4 |
Execution timed out |
3043 ms |
21840 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
19004 KB |
Output is correct |
2 |
Correct |
305 ms |
34820 KB |
Output is correct |
3 |
Correct |
268 ms |
34828 KB |
Output is correct |
4 |
Correct |
288 ms |
34644 KB |
Output is correct |
5 |
Correct |
280 ms |
35152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
244 ms |
20788 KB |
Output is correct |
2 |
Execution timed out |
3055 ms |
37604 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
280 ms |
37716 KB |
Output is correct |
2 |
Execution timed out |
3010 ms |
41040 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
355 ms |
43092 KB |
Output is correct |
2 |
Correct |
404 ms |
43604 KB |
Output is correct |
3 |
Execution timed out |
3072 ms |
43848 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |