Submission #274828

# Submission time Handle Problem Language Result Execution time Memory
274828 2020-08-19T16:23:58 Z Saboon Last supper (IOI12_supper) C++14
100 / 100
141 ms 9700 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;

int last[maxn], nex[maxn];
bool mark[maxn], Good[2*maxn];

void ComputeAdvice(int *C, int N, int K, int M) {
	set<pair<int,int>> S;
	memset(last, 63, sizeof last);
	for (int i = N-1; i >= 0; i--){
		nex[i] = last[C[i]];
		last[C[i]] = i;
	}
	for (int i = 0; i < K; i++){
		S.insert({-last[i], -(i+1)});
		mark[i] = 1;
	}
	for (int i = 0; i < N; i++){
		if (mark[C[i]]){
			auto it = S.lower_bound(make_pair(-i,-maxn));
			int idx = (*it).second;
			if (idx < 0)
				Good[-(idx+1)] = 1;
			else
				Good[idx+K] = 1;
			S.erase(it);
			S.insert({-nex[i], i});
		}
		else{
			auto it = S.begin();
			int idx = (*it).second;
			if (idx < 0){
				Good[-(idx+1)] = 0;
				mark[-(idx+1)] = 0;
			}
			else{
				Good[idx+K] = 0;
				mark[C[idx]] = 0;
			}
			S.erase(it);
			mark[C[i]] = 1;
			S.insert({-nex[i], i});
		}
	}
	for (int i = 0; i < N+K; i++)
		WriteAdvice(Good[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
const int maxn = 1e5 + 10;

bool mark2[maxn];
int C[maxn];
int A[2*maxn];

void Assist(unsigned char *S, int N, int K, int R) {
	set<int> Bad;
	for (int i = 0; i < R; i++)
		A[i] = S[i];
	for (int i = 0; i < K; i++){
		if (A[i] == 0)
			Bad.insert(i);
		mark2[i] = 1;
	}
	for (int i = 0; i < N; i++) {
		int req = GetRequest();
		C[i] = req;
		if (mark2[req]){
			if (A[i+K] == 0)
				Bad.insert(C[i]);
			continue;
		}
		assert(!Bad.empty());
		int idx = *Bad.begin();
		PutBack(idx);
		mark2[idx] = 0;
		mark2[C[i]] = 1;
		Bad.erase(Bad.begin());
		if (A[i+K] == 0)
			Bad.insert(C[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 2 ms 1536 KB Output is correct
3 Correct 3 ms 1536 KB Output is correct
4 Correct 4 ms 1536 KB Output is correct
5 Correct 5 ms 1536 KB Output is correct
6 Correct 6 ms 1584 KB Output is correct
7 Correct 6 ms 1792 KB Output is correct
8 Correct 7 ms 1792 KB Output is correct
9 Correct 7 ms 1792 KB Output is correct
10 Correct 7 ms 1792 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2048 KB Output is correct
2 Correct 52 ms 4352 KB Output is correct
3 Correct 127 ms 9700 KB Output is correct
4 Correct 78 ms 6108 KB Output is correct
5 Correct 84 ms 6080 KB Output is correct
6 Correct 114 ms 6884 KB Output is correct
7 Correct 130 ms 8260 KB Output is correct
8 Correct 106 ms 7976 KB Output is correct
9 Correct 78 ms 6160 KB Output is correct
10 Correct 128 ms 9224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 7152 KB Output is correct
2 Correct 124 ms 8632 KB Output is correct
3 Correct 120 ms 8652 KB Output is correct
4 Correct 127 ms 8892 KB Output is correct
5 Correct 121 ms 8104 KB Output is correct
6 Correct 129 ms 8524 KB Output is correct
7 Correct 123 ms 8524 KB Output is correct
8 Correct 127 ms 8652 KB Output is correct
9 Correct 109 ms 8688 KB Output is correct
10 Correct 123 ms 8652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1792 KB Output is correct
2 Correct 7 ms 1792 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1536 KB Output is correct
5 Correct 6 ms 1536 KB Output is correct
6 Correct 8 ms 1792 KB Output is correct
7 Correct 8 ms 1792 KB Output is correct
8 Correct 9 ms 1792 KB Output is correct
9 Correct 7 ms 1792 KB Output is correct
10 Correct 9 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 8132 KB Output is correct - 120000 bits used
2 Correct 125 ms 8508 KB Output is correct - 122000 bits used
3 Correct 128 ms 8688 KB Output is correct - 125000 bits used
4 Correct 141 ms 8784 KB Output is correct - 125000 bits used
5 Correct 121 ms 8848 KB Output is correct - 125000 bits used
6 Correct 131 ms 8928 KB Output is correct - 125000 bits used
7 Correct 119 ms 8700 KB Output is correct - 124828 bits used
8 Correct 134 ms 8984 KB Output is correct - 124910 bits used
9 Correct 120 ms 8716 KB Output is correct - 125000 bits used
10 Correct 112 ms 8720 KB Output is correct - 125000 bits used