답안 #349910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349910 2021-01-18T16:45:20 Z tengiz05 최후의 만찬 (IOI12_supper) C++17
0 / 100
103 ms 7944 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int NN = 2e5+5;
int n, ans[NN], used[NN], nx[NN], lst[NN];
void ComputeAdvice(int *C, int n, int k, int m) {
	priority_queue<pair<int,int>> q;
	for(int i=0;i<n;i++)lst[C[i]] = n+1, used[i] = -1;
	for(int i=n-1;i>=0;i--){
		nx[C[i]] = lst[C[i]];
		lst[C[i]] = i;
	}
	for(int i=0;i<k;i++){
		q.push({lst[i], i});
		used[i] = i;
	}
	for(int i=0;i<n;i++){
		if(used[C[i]] != -1)ans[used[C[i]]] = 1;
		else {
			while(true){
				int x = q.top().second;q.pop();
				if(used[x] == -1)continue;
				used[x] = -1;
				break;
			}
		}used[C[i]] = k+i;
		q.push({nx[i], C[i]});
	}
	for(int i=0;i<n+k;i++)WriteAdvice(ans[i]);
}

#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
	set<int> x, y;
	for(int i=0;i<k;i++){
		if(A[i] == 0)x.insert(i);
		else y.insert(i);
	}
	for(int i=k;i<n+k;i++){
		int c = GetRequest();
		if(y.find(c) != y.end()){
			y.erase(c);
		}else {
			PutBack(*x.begin());
			x.erase(x.begin());
		}if(A[i] == 0)x.insert(c);
		else y.insert(c);
	}
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 952 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1628 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 6396 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1096 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 81 ms 7564 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 78 ms 7532 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 81 ms 7764 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 79 ms 7768 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 80 ms 7916 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 82 ms 7944 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 92 ms 7756 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 80 ms 7776 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 80 ms 7624 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 103 ms 7276 KB Error - Putting back a color when it is already on the scaffold