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;
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
vector<int> k(n);
vector<int> res;
vector<int> ne;
ne.push_back(1);
for (int i = 0; i< n;i++) cin >> a[i];
for (int i = 0; i< n;i++) cin >> k[i];
for (int i = 1; i< n;i++){
int c = a[i-1];
int b = a[i];
int pop = __builtin_popcount(c&b);
if (pop == k[i]){
ne.push_back(i+1);
}else{
if (ne.size()>res.size()){
res = ne;
ne.clear();
}
}
}
if (ne.size()>res.size()){
res = ne;
}
ne.clear();
for (int i = 1; i< n;i++){
int c = a[i-1];
int b = a[i];
int pop = __builtin_popcount(c&b);
if (pop == k[i]){
ne.push_back(i+1);
}
}
if (ne.size()>res.size()){
res = ne;
ne.clear();
}
cout << res.size() << "\n";
for (int el:res) cout << el << " ";
return 0;
}
# | 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... |