제출 #1052432

#제출 시각아이디문제언어결과실행 시간메모리
1052432kiethm07Longest beautiful sequence (IZhO17_subsequence)C++11
23 / 100
6019 ms2904 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define vii vector<pii> #define pb(i) push_back(i) #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); const int N = 2e5 + 5; int n; int a[N], k[N]; void sub2(){ vector<int> pre(n + 1), dp(n + 1); int p = -1; int ans = 0; for (int i = 1; i <= n; i++){ dp[i] = 1; pre[i] = -1; for (int j = 1; j < i; j++){ if (dp[j] < dp[i]) continue; if (__builtin_popcount(a[i] & a[j]) != k[i]) continue; dp[i] = dp[j] + 1; pre[i] = j; } if (dp[i] > ans){ ans = dp[i]; p = i; } } vector<int> res; while(p != -1){ res.push_back(p); p = pre[p]; } reverse(all(res)); cout << res.size() << "\n"; for (int i : res) cout << i << " "; cout << "\n"; } int main(){ cin.tie(0) -> sync_with_stdio(0); if (fopen(TEXT".inp","r")){ freopen(TEXT".inp","r",stdin); freopen(TEXT".out","w",stdout); } cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> k[i]; sub2(); return 0; }

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

subsequence.cpp: In function 'void sub2()':
subsequence.cpp:54:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   54 |     for (int i : res) cout << i << " "; cout << "\n";
      |     ^~~
subsequence.cpp:54:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   54 |     for (int i : res) cout << i << " "; cout << "\n";
      |                                         ^~~~
subsequence.cpp: In function 'int main()':
subsequence.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         freopen(TEXT".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(TEXT".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...