| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1115124 | adiyer | Longest beautiful sequence (IZhO17_subsequence) | C++17 | 2 ms | 3664 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// #pragma optimize ("g",on)
// #pragma GCC optimize("inline")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC optimize ("03")
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e5 + 2;
const int M = (1 << 10);
ll n, pos;
ll a[N], k[N], par[N], ans[N], dp[M][M][11];
void sol(){
cin >> n, pos = 1;
for(ll i = 1; i <= n; i++) cin >> a[i];
for(ll i = 1; i <= n; i++) cin >> k[i];
for(ll i = 1; i <= n; i++){
for(ll msk = 0; msk < M; msk++){
ll add = k[i] - __builtin_popcount((msk & (a[i] >> 10)));
if(add < 0 || add > 10) continue;
ll j = dp[msk][a[i] % M][add];
if(ans[j] + 1 > ans[i]) ans[i] = ans[j] + 1, par[i] = j;
}
for(ll msk = 0; msk < M; msk++){
ll add = __builtin_popcount((msk & (a[i] % M)));
ll &j = dp[(a[i] >> 10)][msk][add];
if(ans[j] < ans[i]) j = i;
}
if(ans[pos] < ans[i]) pos = i;
}
vector < ll > vec = {pos};
while(vec.size() < ans[vec[0]]) pos = par[pos], vec.pb(pos);
reverse(vec.begin(), vec.end());
cout << vec.size() << '\n';
for(ll x : vec) cout << x << ' ';
}
signed main(){
ios
sol();
// slow();
// stress();
}
컴파일 시 표준 에러 (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... | ||||
