제출 #1030047

#제출 시각아이디문제언어결과실행 시간메모리
1030047phoenixLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
2 ms1624 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100100; const int M = (1 << 10); pair<int, int> ans; int a[N], k[N]; pair<int, int> dp[M][M][10]; int pr[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> k[i]; for (int i = 1; i <= n; i++) { pair<int, int> cur = {0, 0}; for (int f = 0; f < (1 << 10); f++) { int c = k[i] - __builtin_popcount(f & a[i]); if (c >= 0) cur = max(cur, dp[f][a[i] >> 10][c]); } cur.first++; pr[i] = cur.second; cur.second = i; ans = max(ans, cur); for (int f = 0; f < (1 << 10); f++) { int c = __builtin_popcount((a[i] >> 10) & f); dp[(a[i] & M - 1)][f][c] = max(dp[(a[i] & M - 1)][f][c], cur); } } cout << ans.first << '\n'; vector<int> res; while (ans.second) { res.push_back(ans.second); ans.second = pr[ans.second]; } reverse(res.begin(), res.end()); for (int c : res) cout << c << ' '; cout << '\n'; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

subsequence.cpp: In function 'int main()':
subsequence.cpp:36:26: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   36 |             dp[(a[i] & M - 1)][f][c] = max(dp[(a[i] & M - 1)][f][c], cur);
      |                        ~~^~~
subsequence.cpp:36:57: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   36 |             dp[(a[i] & M - 1)][f][c] = max(dp[(a[i] & M - 1)][f][c], cur);
      |                                                       ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...