답안 #556155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556155 2022-05-02T14:03:35 Z keta_tsimakuridze 최후의 만찬 (IOI12_supper) C++14
0 / 100
182 ms 15344 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
const int nn = 2e5 + 5;
vector<int> x[nn];
int cur[nn], save[nn], last[nn];
void ComputeAdvice(int *C, int N, int K, int M) {
	
	for(int i = N - 1; i >= 0; i--) {
		x[C[i]].push_back(i + K);
	}
	set<pair<int,int> > s;
	for(int i = 0; i < K; i++) {
		cur[i] = 1;
		s.insert({x[i].size() ? x[i].back() : N + K, i});
		if(x[i].size()) x[i].pop_back();
		last[i] = i;
	}
	
	for(int i = K; i < N + K; i++) {
		int c = C[i - K];
		
		if(cur[c]) {
			save[last[c]] = 1;
			s.erase({i, c});
		}
		else {
			pair<int,int> p = *--s.end();
			s.erase(p);
			cur[p.second] = 0;
		}
		cur[c] = 1;
		s.insert({(x[c].size() ? x[c].back() : N + K), c});
		if(x[c].size()) x[c].pop_back();

		last[c] = i;
	}
	
	for(int i = 0; i < N + K; i++) WriteAdvice(save[i]);
}
#include<bits/stdc++.h>
using namespace std;
#include "assistant.h"
const int nn = 2e5 + 5;
int last[nn], cur[nn];

void Assist(unsigned char *A, int N, int K, int R) {
	set<pair<int,int> > s;
	for(int i = 0; i < K; i++) {
		last[i] = i;
		s.insert({A[i], i});
		cur[i] = 1;
	}
	for(int i = K; i < N + K; i++) {
		int c = GetRequest();
		if(cur[c]) {
			s.erase({A[last[c]], c});
			last[c] = i;
			s.insert({A[i], c});
			continue;
		}
		cur[c] = 1;
		pair<int,int> p = *s.begin();
		PutBack(p.second);
		s.erase(p);
		cur[p.second] = 0;
		s.insert({A[i], c});
		last[c] = i;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5268 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 6232 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 114 ms 13268 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 5672 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 128 ms 14700 KB Output isn't correct - not an optimal way
2 Incorrect 163 ms 14904 KB Output isn't correct - not an optimal way
3 Incorrect 141 ms 15244 KB Output isn't correct - not an optimal way
4 Incorrect 132 ms 15332 KB Output isn't correct - not an optimal way
5 Incorrect 153 ms 15264 KB Output isn't correct - not an optimal way
6 Incorrect 182 ms 15292 KB Output isn't correct - not an optimal way
7 Incorrect 128 ms 15344 KB Output isn't correct - not an optimal way
8 Incorrect 137 ms 15344 KB Output isn't correct - not an optimal way
9 Incorrect 134 ms 15232 KB Output isn't correct - not an optimal way
10 Incorrect 129 ms 15180 KB Output isn't correct - not an optimal way