Submission #94432

#TimeUsernameProblemLanguageResultExecution timeMemory
94432KastandaLongest beautiful sequence (IZhO17_subsequence)C++11
0 / 100
7 ms1912 KiB
#include<bits/stdc++.h> using namespace std; const int N = 100005, SQ = 1024; int n, ts, A[N], K[N], P[N], R[N]; pair < int , int > dp[SQ+1][SQ+1][11+1]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &A[i]); for (int i = 1; i <= n; i++) scanf("%d", &K[i]); int nw = 0, _max = 0; for (int i = 1; i <= n; i++) { int a = A[i], k = K[i]; pair < int , int > Mx = {0, 0}; for (int j = 0; j < SQ; j++) { int kk = k - __builtin_popcount((a >> 10) & j); if (kk >= 0 && kk <= 10) Mx = max(Mx, dp[j][a & (SQ - 1)][k]); } Mx.first ++; P[i] = Mx.second; Mx.second = i; for (int j = 0; j < SQ; j++) { int kk = __builtin_popcount(a & (SQ - 1) & j); dp[a >> 10][j][kk] = max(dp[a >> 10][j][kk], Mx); } if (Mx.first > _max) _max = Mx.first, nw = i; } while (nw) { R[ts ++] = nw; nw = P[nw]; } printf("%d\n", ts); for (int i = ts - 1; ~i; i--) printf("%d ", R[i]); return 0; }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
subsequence.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
subsequence.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &K[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...