#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){
if(x==n/3){
for(int i=0;i<3005;i++){
if(curr[i]==1) co i<<' ';
}
exit(0);
}
ll num=rand()%n+1;
while(vis[num]||(curr&mat[num])!=curr) num=rand()%n+1;
vis[num]=1;
curr[num]=1;
rec1(x+1);
curr[num]=0;
vis[num]=0;
}
void solve(){
cin>>n>>m;
for(int i=0;i<m;i++){
ll a,b;
cin>>a>>b;
mat[a][b]=1;
mat[b][a]=1;
}
if(n<=50) rec(0);
else while(1) rec1(0);
}
int main()
{
suiii
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3048 ms |
604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
604 KB |
Output is correct |
2 |
Correct |
29 ms |
856 KB |
Output is correct |
3 |
Correct |
29 ms |
856 KB |
Output is correct |
4 |
Execution timed out |
3040 ms |
856 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
600 KB |
Output is correct |
2 |
Correct |
70 ms |
1108 KB |
Output is correct |
3 |
Correct |
68 ms |
1104 KB |
Output is correct |
4 |
Correct |
61 ms |
1068 KB |
Output is correct |
5 |
Correct |
66 ms |
1064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1108 KB |
Output is correct |
2 |
Execution timed out |
3085 ms |
1168 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
1060 KB |
Output is correct |
2 |
Correct |
120 ms |
1360 KB |
Output is correct |
3 |
Execution timed out |
3024 ms |
1240 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
1504 KB |
Output is correct |
2 |
Execution timed out |
3064 ms |
1372 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
176 ms |
1616 KB |
Output is correct |
2 |
Correct |
223 ms |
1704 KB |
Output is correct |
3 |
Correct |
224 ms |
1620 KB |
Output is correct |
4 |
Execution timed out |
3072 ms |
1448 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
197 ms |
1700 KB |
Output is correct |
2 |
Execution timed out |
3064 ms |
1756 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
231 ms |
1772 KB |
Output is correct |
2 |
Execution timed out |
3081 ms |
1828 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
279 ms |
1868 KB |
Output is correct |
2 |
Execution timed out |
3044 ms |
1624 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |