Submission #502591

#TimeUsernameProblemLanguageResultExecution timeMemory
502591AktanLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define int long long #define ft first #define sc second using namespace std; const int mod=1e9+7,INF=1e17,N=1e5; int dp[5005][5005],a[5005],b[5005]; main(){ int n; cin >> n; for(int i=1;i<=n;i++){ cin >> a[i]; } for(int i=1;i<=n;i++){ cin >> b[i]; } int ans=-1,m=1; for(int i=1;i<=n;i++){ int k=a[i],h=b[i]; int res=1; dp[i][i]++; for(int j=i-1;j>=1;j--){ if(__builtin_popcount((k&a[j]))==h){ k=a[j]; h=b[j]; dp[i][j]++; res++; } } if(res>m){ ans=i; m=res; } } if(m==1){ cout << 1 << endl; cout << 1; } else{ cout << ans << endl; for(int i=1;i<=n;i++){ if(dp[ans][i]!=0){ cout << i << " "; } } } }

Compilation message (stderr)

subsequence.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...