제출 #898338

#제출 시각아이디문제언어결과실행 시간메모리
898338AI_2512Longest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
1 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]; int left = 0, right = 1; 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(); while (right < n-1){ long long pop = __builtin_popcountll(a[left]&a[right]); if (pop == k[right]){ ne.push_back(a[right]); left = right; } right++; } if (ne.size()>res.size()){ res = ne; } 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...