# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
541066 | creeped | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 8 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll a[20], k[20];
vector<ll> ans;
ll popcount(ll x)
{
ll res = 0;
while(x)
{
res += x&1;
x >>= 1;
}
return res;
}
int main() {
cin>>n;
if(n > 15)
{
cout<<0;
return 0;
}
for(ll i=1;i<=n;i++)
cin>>a[i];
for(ll i=1;i<=n;i++)
cin>>k[i];
for(ll i=1;i<(1<<n); i++)
{
vector<ll> cur;
for(ll j=0;j<n;j++)
if(i&(1<<j))
cur.push_back(j+1);
bool flag = 0;
for(ll j=0;j<cur.size();j++)
{
for(ll h=j+1;h<cur.size();h++)
if(popcount(a[cur[j]] & a[cur[h]]) != k[cur[h]])
{
flag = 1;
break;
}
if(flag)
break;
}
if(flag)
continue;
//cout<<1<<endl;
if(cur.size() > ans.size())
ans = cur;
}
cout<<ans.size()<<endl;
for(auto it:ans)
cout<<it<<" ";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |