# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167114 | abil | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 1208 ms | 262148 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 fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long
using namespace std;
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);
int a[N], k[N];
vector<int > vec[N];
main()
{
int n;
cin >> n;
for(int i = 1;i <= n; i++){
scanf("%d", &a[i]);
vec[i].pb(i);
}
for(int j = 1;j <= n; j++){
scanf("%d", &k[j]);
}
vector<int > ans;
for(int i = n;i >= 1; i--){
for(int j = i + 1;j <= n; j++){
if(vec[i].size() <= vec[j].size() && __builtin_popcount((a[i] & a[j])) == k[j]){
vec[i] = vec[j];
vec[i].pb(i);
}
}
if(vec[i].size() > ans.size()){
ans = vec[i];
}
}
cout << ans.size() << endl;
reverse(all(ans));
for(auto to : ans){
cout << to << " ";
}
}
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... |