제출 #1006637

#제출 시각아이디문제언어결과실행 시간메모리
1006637Essa2006Longest beautiful sequence (IZhO17_subsequence)C++14
40 / 100
79 ms4440 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n; cin >> n; vector<int> A(n), K(n); for (int i = 0; i < n; i++) { cin >> A[i]; } for (int i = 0; i < n; i++) { cin >> K[i]; } int ans = 0; vector<array<int, 2>> dp(n), dp2(256); for (int i = 0; i < n; i++) { dp[i][0] = 1, dp[i][1] = -1; if (n > 5000) { for (int j = 0; j < 256; j++) { int res = (A[i] & j); if (__builtin_popcount(res) != K[i]) { continue; } if (dp2[j][0] + 1 > dp[i][0]) { dp[i][0] = dp2[j][0] + 1, dp[i][1] = dp2[j][1]; } } if (dp[i][0] > dp2[A[i]][0]) { dp2[A[i]][0] = dp[i][0], dp2[A[i]][1] = i; } } else { for (int j = 0; j < i; j++) { int res = (A[i] & A[j]); if (__builtin_popcount(res) == K[i]) { if (dp[j][0] + 1 > dp[i][0]) { dp[i][0] = dp[j][ 0] + 1; dp[i][1] = j; } } } } if (dp[i][0] > dp[ans][0]) { ans = i; } } vector<int> Ans; Ans.push_back(ans + 1); while (dp[ans][1] != -1) { ans = dp[ans][1]; Ans.push_back(ans + 1); } reverse(all(Ans)); cout << Ans.size() << endl; for (int i = 0; i < Ans.size(); i++) { cout << Ans[i] << ' '; } }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:69:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     for (int i = 0; i < Ans.size(); 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...