# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
745094 | 2023-05-19T11:45:37 Z | sword060 | Hiperkocka (COCI21_hiperkocka) | C++17 | 2 ms | 3284 KB |
#include <bits/stdc++.h> using namespace std; const int N=1<<16; int x; vector<int>all; set<int>v[N]; set<vector<int>>ans; int main(){ ios::sync_with_stdio(0);cin.tie(0); srand(time(NULL)); cin>>x; if(x==1){ cout<<"1\n0 1\n"; return 0; } for(int i=1;i<=x;i++){ int l,r;cin>>l>>r; v[l].insert(r);v[r].insert(l); } for(int i=0;i<(1<<x);i++) all.push_back(i); for(int rep=0;rep<(1<<(x+1));rep++){ random_shuffle(all.begin(),all.end()); vector<int>cur; bool f=1; for(int i=0;i<=x;i++){ cur.push_back(all[i]); for(int j=i+1;j<=x;j++){ int f1=v[i].count(j)+v[j].count(i),f2=0; for(int c=0;c<=16;c++)f2|=((all[i]^all[j])==(1<<c)); if((f1>0)^f2)f=0; } } f&=(ans.find(cur)==ans.end()); if(f){ vector<int>xd=cur; sort(xd.begin(),xd.end()); ans.insert(xd); } if(ans.size()==(1<<(x-1)))break; } cout<<(ans.size())<<"\n"; for(auto i:ans){ for(auto j:i)cout<<j<<" "; cout<<"\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 3284 KB | Edge is not in hipercube |
2 | Halted | 0 ms | 0 KB | - |