# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
892565 | NoLove | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 6020 ms | 3932 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* author : Lăng Trọng Đạt
* created: 25-12-2023
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int int64_t
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
const int MAXN = 1e5 + 5;
int g[MAXN], k[MAXN], dp[MAXN], p[MAXN];
int n;
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("hi.inp", "r")) {
freopen("hi.inp", "r", stdin);
// freopen("hi.out", "w", stdout);
}
std::cin >> n;
for (int i = 0; i < n; i++) {
dp[i] = 1;
p[i] = i;
std::cin >> g[i];
}
for (int i = 0; i < n; i++) {
std::cin >> k[i];
}
int id = 0;
for (int i = 1; i < n; i++) {
for (int j = 0; j < i; j++) {
if (__builtin_popcount(g[i] & g[j]) == k[i] && dp[j] + 1 > dp[i]) {
dp[i] = dp[j] + 1;
p[i] = j;
}
}
if (dp[i] > dp[id]) {
id = i;
}
}
cout << dp[id] << "\n";
// cout << id << " ";
vector<int> ans = {id};
while (id != p[id]) {
id = p[id];
ans.pb(id);
// cout << id << " ";
}
for (int i = ans.size() - 1; i >= 0; i--) {
cout << ans[i] + 1 << " ";
}
}
컴파일 시 표준 에러 (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... |