| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 93050 | Vardanyan | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 7 ms | 1144 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1000 * 100 + 5;
const int M = (1 << 11);
int dp[M][21][M];
int dp_pos[M][21][M];
int a[N];
int K[N];
int par[N];
int cnt[N];
int CNT(int n){
	if(cnt[n]) return cnt[n];
	int ans = 0;
	for (int i = 0; i < 21; i++) if ((n >> i) & 1) ans++;
	return cnt[n] =  ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> K[i];
	int lst = 1;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		int u = a[i] >> 10;
		int l = a[i]%1024;
		int w = 0;
		int w_p = 0;
		for (int mask = 0; mask < M; mask++){
			int bt = CNT(u&mask);
			int need = K[i] - bt;
          	if(need>10 || need<0) continue;
			int now = dp[mask][need][l]+1;
			if (now > w){
				w = now;
				w_p = dp_pos[mask][need][l];
			}
		}
				if (w > ans){
					ans = w;
					lst = i;
				}
		par[i] = w_p;
		for (int mask = 0; mask < M; mask++){
			int q = CNT(l&mask);
			if (dp[u][q][mask] < w){
				dp[u][q][mask] = w;
				dp_pos[u][q][mask] = i;
			}
		}
	}
	vector<int> all;
	all.push_back(lst);
	while (par[lst]){
		lst = par[lst];
		all.push_back(lst);
	}
	reverse(all.begin(), all.end());
	cout << ans << endl;
	for (int i = 0; i < all.size(); i++){
		cout << all[i] << endl;
	}
	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... | ||||
