Submission #578756

#TimeUsernameProblemLanguageResultExecution timeMemory
578756jeroenodbLongest beautiful sequence (IZhO17_subsequence)C++14
0 / 100
1 ms212 KiB
#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int mxN = 1e5+1, oo = 1e9; int main() { int n; cin >> n; vi a(n); vector<short> k(n); for(auto& i : a) cin >> i; for(auto& i : k) cin >> i; vi dp(n); for(int i=0;i<n;++i) { for(int j=0;j<n;++j) if(__builtin_popcount(a[i]&a[j])==k[i]){ dp[i] = max(dp[i],dp[j]); } dp[i]++; } cout << *max_element(all(dp)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...