# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
541112 | Bunny_man | Longest beautiful sequence (IZhO17_subsequence) | C++17 | 8 ms | 468 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>
#define ll long long int
#define pb push_back
#define ui unsigned int
#define ld long double
#define buster ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
vector<ll> ans;
ll a[101];
ll b[101];
ll bitcount(ll k)
{
ll cnt = 0;
while(k)
{
cnt += k&1;
k >>= 1;
}
return cnt;
}
int main()
{
buster;
ll tt = 1;
//cin >> tt;
while(tt--)
{
ll n;
cin >> n;
for(ll i = 1; i <= n; i++)
{
cin >> a[ i ];
}
for(ll i = 1; i <= n; i++)
{
cin >> b[ i ];
}
for(ll mask = 1; mask < (1 << n); mask++)
{
vector <ll> cur;
for(ll i = 0; i < n; i++)
{
if(mask & (1 << i))
{
cur.pb(i + 1);
}
}
bool flag = 0;
for(ll i = 0; i < cur.size(); i++)
{
for(ll j = i + 1; j < cur.size(); j++)
{
if(bitcount(a[ cur[ i ] ] & a[ cur[ j ] ]) != b[ cur[ j ] ])
{
flag = 1;
break;
}
}
if(flag)
{
break;
}
}
if(flag)
{
continue;
}
if(cur.size() > ans.size())
{
ans = cur;
}
}
cout << ans.size() << "\n";
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... |