# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580200 | 2022-06-20T17:27:29 Z | FatihSolak | Present (RMI21_present) | C++17 | 1631 ms | 4520 KB |
#include <bits/stdc++.h> #define N 20 #define K 20 using namespace std; int cnt[1<<N]; int g[N+K][N+K]; bool exist[N+K]; bool ck(vector<int> a){ for(auto u:a){ exist[u] = 1; } bool ok = 1; for(auto u:a){ for(auto c:a){ ok &= exist[g[u][c]]; } } for(auto u:a){ exist[u] = 0; } return ok; } vector<int> ans; vector<int> get(int mask,int k){ vector<int> unused; for(int i = 0;i<N;i++){ if( !(mask & (1<<i))) unused.push_back(i+1); } for(int mask2 = 0;mask2 < (1<<unused.size());mask2++){ vector<int> now; for(int i = 0;i<N;i++){ if(mask & (1<<i)) now.push_back(i+1); } for(int i = 0;i<unused.size();i++){ if(mask2 & (1<<i)) now.push_back(unused[i]); } sort(now.begin(),now.end()); if(ck(now))k--; if(k == 0) return now; } } void solve(){ int k; cin >> k; k++; for(int mask = 0;mask < (1<<K);mask++){ vector<int> now; for(int i = 0;i<K;i++){ if(mask & (1<<i)) now.push_back(N+i+1); } int mask2 = 0; for(auto u:now){ for(auto c:now){ if(u == c)continue; mask2 |= (1 << (g[u][c] - 1)); } } if(cnt[mask2] >= k){ //cout << "hey" << endl; ans.clear(); //cout << mask2 << " " << k << endl; for(auto u:get(mask2,k)){ ans.push_back(u); } for(auto u:now){ ans.push_back(u); } break; } else k -= cnt[mask2]; } cout << ans.size() << " "; for(auto u:ans){ cout << u << " "; } cout << "\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif for(int i = 0;i<N+K;i++){ for(int j = 0;j<N+K;j++){ g[i][j] = __gcd(i,j); } } for(int mask = 0;mask<(1<<N);mask++){ vector<int> now; for(int i = 0;i<N;i++){ if(mask & (1<<i)) now.push_back(i+1); } if(!ck(now))continue; for(int mask2 = mask;;){ cnt[mask2]++; if(mask2 == 0)break; mask2 = (mask2 - 1) & mask; } } int t = 1; cin >> t; while(t--){ solve(); } #ifdef Local cout << endl << fixed << setprecision(2) << 1000.0*clock()/CLOCKS_PER_SEC << " milliseconds."; #endif }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 912 ms | 4368 KB | Output is correct |
2 | Correct | 928 ms | 4520 KB | Output is correct |
3 | Correct | 904 ms | 4444 KB | Output is correct |
4 | Correct | 900 ms | 4360 KB | Output is correct |
5 | Correct | 902 ms | 4352 KB | Output is correct |
6 | Correct | 914 ms | 4456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 912 ms | 4368 KB | Output is correct |
2 | Correct | 928 ms | 4520 KB | Output is correct |
3 | Correct | 904 ms | 4444 KB | Output is correct |
4 | Correct | 900 ms | 4360 KB | Output is correct |
5 | Correct | 902 ms | 4352 KB | Output is correct |
6 | Correct | 914 ms | 4456 KB | Output is correct |
7 | Incorrect | 1631 ms | 4472 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 912 ms | 4368 KB | Output is correct |
2 | Correct | 928 ms | 4520 KB | Output is correct |
3 | Correct | 904 ms | 4444 KB | Output is correct |
4 | Correct | 900 ms | 4360 KB | Output is correct |
5 | Correct | 902 ms | 4352 KB | Output is correct |
6 | Correct | 914 ms | 4456 KB | Output is correct |
7 | Incorrect | 1631 ms | 4472 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 912 ms | 4368 KB | Output is correct |
2 | Correct | 928 ms | 4520 KB | Output is correct |
3 | Correct | 904 ms | 4444 KB | Output is correct |
4 | Correct | 900 ms | 4360 KB | Output is correct |
5 | Correct | 902 ms | 4352 KB | Output is correct |
6 | Correct | 914 ms | 4456 KB | Output is correct |
7 | Incorrect | 1631 ms | 4472 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 912 ms | 4368 KB | Output is correct |
2 | Correct | 928 ms | 4520 KB | Output is correct |
3 | Correct | 904 ms | 4444 KB | Output is correct |
4 | Correct | 900 ms | 4360 KB | Output is correct |
5 | Correct | 902 ms | 4352 KB | Output is correct |
6 | Correct | 914 ms | 4456 KB | Output is correct |
7 | Incorrect | 1631 ms | 4472 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |