Submission #556438

# Submission time Handle Problem Language Result Execution time Memory
556438 2022-05-03T07:06:13 Z keta_tsimakuridze Last supper (IOI12_supper) C++17
0 / 100
169 ms 17732 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]) {
			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;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5268 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 6396 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 15104 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5820 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 16608 KB Output isn't correct - not an optimal way
2 Incorrect 147 ms 17136 KB Output isn't correct - not an optimal way
3 Incorrect 132 ms 17732 KB Output isn't correct - not an optimal way
4 Incorrect 125 ms 17616 KB Output isn't correct - not an optimal way
5 Incorrect 169 ms 17652 KB Output isn't correct - not an optimal way
6 Incorrect 128 ms 17588 KB Output isn't correct - not an optimal way
7 Incorrect 135 ms 17628 KB Output isn't correct - not an optimal way
8 Incorrect 151 ms 17652 KB Output isn't correct - not an optimal way
9 Incorrect 125 ms 17620 KB Output isn't correct - not an optimal way
10 Incorrect 152 ms 16840 KB Output isn't correct - not an optimal way