제출 #763061

#제출 시각아이디문제언어결과실행 시간메모리
763061AloraLongest beautiful sequence (IZhO17_subsequence)C++17
7 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define name "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define f first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define pb push_back #define all(v) v.begin(), v.end() #define maxn 100005 const int M = 1e9 + 7; using namespace std; int n, a[maxn], k[maxn]; void sub1(){ int res = 1, luu = 1; fi(msk, 1, (1 << n) - 1){ int id = __builtin_ctz(msk); int sl = __builtin_popcount(msk); if(sl < 2) continue; int pre = id, ok = 1; fi(i, id + 1, n - 1) if(getbit(msk, i)){ if(__builtin_popcount(a[i + 1] & a[pre + 1]) != k[i + 1]){ ok = 0; break; } else pre = i; } if(!ok) continue; if(sl > res) res = sl, luu = msk; } cout << res << '\n'; fi(i, 0, n - 1) if(getbit(luu, i)) cout << i + 1 << " "; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); // freopen(name".in", "r", stdin); // freopen(name".out", "w", stdout); cin >> n; fi(i, 1, n) cin >> a[i]; fi(i, 1, n) cin >> k[i]; if(n <= 15) sub1(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...