Submission #956092

#TimeUsernameProblemLanguageResultExecution timeMemory
956092Trisanu_DasLongest beautiful sequence (IZhO17_subsequence)C++17
23 / 100
6048 ms2396 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; pair<int, int> ans; vector<int> a(n), b(n), dp(n), par(n, -1); for(int &p : a) cin >> p; for(int &p : b) cin >> p; for(int i=0; i<n; i++) { for(int j=0; j<i; j++) if(__builtin_popcount(a[i]&a[j])==b[i]) if(dp[j]>dp[i]) dp[i]=dp[j], par[i]=j; ans=max(ans, {++dp[i], i}); } deque<int> lbs; cout << ans.first << '\n'; int idx=ans.second; while(idx!=-1) { lbs.push_front(idx); idx=par[idx]; } for(int p : lbs) cout << p+1 << ' '; cout << '\n'; }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:21:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   21 |  for(int p : lbs) cout << p+1 << ' '; cout << '\n';
      |  ^~~
subsequence.cpp:21:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   21 |  for(int p : lbs) cout << p+1 << ' '; cout << '\n';
      |                                       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...