# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
883509 | skywwla | Longest beautiful sequence (IZhO17_subsequence) | C++17 | 6043 ms | 1884 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
int32_t main() {
ios::sync_with_stdio(false) ;
cin.tie(nullptr) ;
int n ; scanf("%d", &n) ;
vector<int> a(n), k(n), dp(n, 1), pr(n, -1) ;
for (int &i : a) scanf("%d", &i) ;
for (int &i : k) scanf("%d", &i) ;
for (int i = 0 ; i < n ; i++) {
for (int j = 0 ; j < i ; j++) {
if (__builtin_popcount(a[i] & a[j]) == k[i] && dp[j] + 1 > dp[i]) {
dp[i] = dp[j] + 1 ;
pr[i] = j ;
}
}
}
int pos = max_element(dp.begin(), dp.end()) - dp.begin() ;
cout << dp[pos] << "\n" ;
vector<int> res ;
while (pos != -1) {
res.push_back(pos) ;
pos = pr[pos] ;
}
reverse(res.begin(), res.end()) ;
for (int i : res) printf("%d ", i + 1) ;
return 0 ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |