Submission #1005430

# Submission time Handle Problem Language Result Execution time Memory
1005430 2024-06-22T12:36:11 Z Almonther Party (POI11_imp) C++
0 / 100
316 ms 2908 KB
#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;
    if(last==-1){
        num=rand()%n+1;
        while(vis[num]||(curr&mat[num])!=curr) num=rand()%n+1;
    }
    else{
        num=v[last][rand()%v[last].size()];
        while(vis[num]||(curr&mat[num])!=curr) 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;
        mat[a][b]=1;
        mat[b][a]=1;
    }
    if(n<=50) rec(0);
    else while(1) rec1(0,-1);
}
int main()
{
    suiii
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 8
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 860 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 860 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 1116 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 1356 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 68 ms 1620 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 2012 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 177 ms 2400 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 197 ms 2468 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 242 ms 2644 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 316 ms 2908 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -