(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #50313

#제출 시각아이디문제언어결과실행 시간메모리
50313mra2322001Longest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
5649 ms110696 KiB
#include <bits/stdc++.h> #define f0(i, n) for(int i=(0); i<n; i++) #define f1(i, n) for(int i=(1); i<=n; i++) using namespace std; typedef long long ll; const int N = 1e5 + 3; int n, a[N], k[N], f[1024][1024][11]; int d[N], trace[N]; main(){ ios_base::sync_with_stdio(0); cin >> n; f1(i, n) cin >> a[i]; f1(i, n) cin >> k[i]; f1(i, n){ int l = a[i] >> 10; int r = 1023 & a[i], best = 0; f0(j, 1024){ int kb = __builtin_popcount(j&r); kb = k[i] - kb; if(kb < 0 || kb > 10) continue; if(d[best] < d[f[l][j][kb]]) best = f[l][j][kb]; } d[i] = d[best] + 1; trace[i] = best; f0(j, 1024){ /// f[j][r][kb] int kb = __builtin_popcount(l&j); if(d[i] > d[f[j][r][kb]]){ f[j][r][kb] = i; } } } int ans = 0; f1(i, n) if(d[i] > d[ans]) ans = i; cout << d[ans] << endl; vector <int> save; for(ans; ans > 0; ans = trace[ans]) save.push_back(ans); for(int i = save.size() - 1; i >= 0; i--) cout << save[i] << " "; }

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

subsequence.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
subsequence.cpp: In function 'int main()':
subsequence.cpp:41:13: warning: statement has no effect [-Wunused-value]
      for(ans; ans > 0; ans = trace[ans]) save.push_back(ans);
             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...