답안 #349913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349913 2021-01-18T16:51:05 Z tengiz05 최후의 만찬 (IOI12_supper) C++17
100 / 100
131 ms 8196 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[i] = n, used[i] = -1;
	for(int i=n-1;i>=0;i--){
		nx[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 Correct 1 ms 952 KB Output is correct
2 Correct 2 ms 744 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 3 ms 1184 KB Output is correct
5 Correct 3 ms 1056 KB Output is correct
6 Correct 6 ms 1096 KB Output is correct
7 Correct 6 ms 1260 KB Output is correct
8 Correct 5 ms 1056 KB Output is correct
9 Correct 5 ms 928 KB Output is correct
10 Correct 6 ms 1188 KB Output is correct
11 Correct 6 ms 1300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1528 KB Output is correct
2 Correct 51 ms 4116 KB Output is correct
3 Correct 127 ms 7912 KB Output is correct
4 Correct 71 ms 6176 KB Output is correct
5 Correct 81 ms 6392 KB Output is correct
6 Correct 100 ms 6652 KB Output is correct
7 Correct 118 ms 7404 KB Output is correct
8 Correct 91 ms 6632 KB Output is correct
9 Correct 76 ms 6068 KB Output is correct
10 Correct 131 ms 8196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 5552 KB Output is correct
2 Correct 122 ms 7580 KB Output is correct
3 Correct 128 ms 7696 KB Output is correct
4 Correct 126 ms 7796 KB Output is correct
5 Correct 118 ms 7380 KB Output is correct
6 Correct 124 ms 7692 KB Output is correct
7 Correct 124 ms 7676 KB Output is correct
8 Correct 103 ms 7468 KB Output is correct
9 Correct 123 ms 7540 KB Output is correct
10 Correct 124 ms 7900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1028 KB Output is correct
2 Correct 5 ms 1080 KB Output is correct
3 Correct 5 ms 1056 KB Output is correct
4 Correct 5 ms 1056 KB Output is correct
5 Correct 5 ms 1096 KB Output is correct
6 Correct 5 ms 928 KB Output is correct
7 Correct 6 ms 1056 KB Output is correct
8 Correct 6 ms 1184 KB Output is correct
9 Correct 6 ms 1300 KB Output is correct
10 Correct 7 ms 1356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 6572 KB Output is correct - 120000 bits used
2 Correct 125 ms 6652 KB Output is correct - 122000 bits used
3 Correct 125 ms 6528 KB Output is correct - 125000 bits used
4 Correct 128 ms 6632 KB Output is correct - 125000 bits used
5 Correct 124 ms 6604 KB Output is correct - 125000 bits used
6 Correct 123 ms 6628 KB Output is correct - 125000 bits used
7 Correct 125 ms 6480 KB Output is correct - 124828 bits used
8 Correct 126 ms 6628 KB Output is correct - 124910 bits used
9 Correct 123 ms 6752 KB Output is correct - 125000 bits used
10 Correct 110 ms 6472 KB Output is correct - 125000 bits used