제출 #898170

#제출 시각아이디문제언어결과실행 시간메모리
898170AI_2512Longest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); long long n; cin >> n; vector<long long> a(n); vector<long long> k(n); vector<long long> res; vector<long long> ne; ne.push_back(1); for (long long i = 0; i< n;i++) cin >> a[i]; for (long long i = 0; i< n;i++) cin >> k[i]; for (long long i = 1; i< n;i++){ long long c = a[i-1]; long long b = a[i]; long long pop = __builtin_popcountll(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 (long long i = 1; i< n;i++){ long long c = a[i-1]; long long b = a[i]; long long pop = __builtin_popcountll(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 (long long el:res) cout << el << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...