Submission #556139

# Submission time Handle Problem Language Result Execution time Memory
556139 2022-05-02T13:20:55 Z keta_tsimakuridze Last supper (IOI12_supper) C++14
0 / 100
115 ms 16000 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, 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), 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] - '0', i});
		cur[i] = 0;
	}
	for(int i = K; i < N + K; i++) {
		int c = GetRequest();
		if(cur[c]) {
			s.erase({A[last[c]] - '0', c});
			last[c] = i;
			s.insert({A[i] - '0', c});
			continue;
		}
		pair<int,int> p = *s.begin();
		PutBack(p.second);
		s.erase(p);
		s.insert({A[i] - '0', c});
		last[c] = i;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5264 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 6292 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 13724 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 5764 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 15264 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 100 ms 15528 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 96 ms 15904 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 95 ms 15884 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 98 ms 15948 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 95 ms 16000 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 115 ms 15924 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 103 ms 15940 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 95 ms 15924 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 93 ms 15924 KB Error - Putting back a color when it is already on the scaffold