Submission #61275

# Submission time Handle Problem Language Result Execution time Memory
61275 2018-07-25T14:41:54 Z aome Last supper (IOI12_supper) C++17
100 / 100
352 ms 30416 KB
#include <bits/stdc++.h>

#include "advisor.h"

using namespace std;

const int maxn = 200005;

int f1[maxn], f2[maxn], f3[maxn];
bool del[maxn];

void ComputeAdvice(int *C, int N, int K, int M) {
	for (int i = 0; i < N; ++i) f1[i] = N;
	for (int i = N - 1; i >= 0; --i) {
		f2[i] = f1[C[i]], f1[C[i]] = i;
	} 
	for (int i = 0; i < K; ++i) f2[i + N] = f1[i];
	set< pair<int, int> > s;
	for (int i = 0; i < N; ++i) f3[i] = -1;
	for (int i = 0; i < K; ++i) {
		f3[i] = i + N, s.insert({f2[i + N], i + N});
	}
	for (int i = 0; i < N; ++i) {
		int &tmp = f3[C[i]];
		set< pair<int, int> > :: iterator it;
		if (tmp == -1) {
			it = --s.end();
			int p = it -> second;
			del[p] = 1;
			if (p > N) f3[p - N] = -1;
			else f3[C[p]] = -1;
		}
		else {
			it = s.find({f2[tmp], tmp});
			assert(it != s.end());
		}
		s.erase(it);
		tmp = i;
		s.insert({f2[i], i});
	}
	for (auto i : s) del[i.second] = 1;
	for (int i = 0; i < N + K; ++i) WriteAdvice(del[i]);
}
#include <bits/stdc++.h>

#include "assistant.h"

using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
	set<int> s1, s2;
	for (int i = 0; i < K; ++i) {
		s1.insert(i);
		if (A[i + N]) s2.insert(i); 
	}
	for (int i = 0; i < N; ++i) {
		int tmp = GetRequest();
		if (s1.find(tmp) == s1.end()) {
			assert(s2.size());
			int p = *s2.begin();
			assert(s1.find(p) != s1.end());
			s1.erase(p), s2.erase(p);
			PutBack(p);
			s1.insert(tmp);
		}
		if (A[i]) s2.insert(tmp);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 736 KB Output is correct
2 Correct 7 ms 1204 KB Output is correct
3 Correct 7 ms 1416 KB Output is correct
4 Correct 9 ms 1480 KB Output is correct
5 Correct 10 ms 1624 KB Output is correct
6 Correct 10 ms 1764 KB Output is correct
7 Correct 12 ms 1824 KB Output is correct
8 Correct 13 ms 1840 KB Output is correct
9 Correct 16 ms 2024 KB Output is correct
10 Correct 17 ms 2424 KB Output is correct
11 Correct 18 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2532 KB Output is correct
2 Correct 80 ms 5568 KB Output is correct
3 Correct 352 ms 12808 KB Output is correct
4 Correct 124 ms 13128 KB Output is correct
5 Correct 160 ms 13128 KB Output is correct
6 Correct 215 ms 13128 KB Output is correct
7 Correct 283 ms 15648 KB Output is correct
8 Correct 232 ms 16224 KB Output is correct
9 Correct 121 ms 16224 KB Output is correct
10 Correct 305 ms 20048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 20048 KB Output is correct
2 Correct 254 ms 20344 KB Output is correct
3 Correct 310 ms 21664 KB Output is correct
4 Correct 294 ms 22880 KB Output is correct
5 Correct 267 ms 23264 KB Output is correct
6 Correct 316 ms 25208 KB Output is correct
7 Correct 316 ms 26360 KB Output is correct
8 Correct 274 ms 27512 KB Output is correct
9 Correct 210 ms 28408 KB Output is correct
10 Correct 306 ms 29824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 29824 KB Output is correct
2 Correct 18 ms 29824 KB Output is correct
3 Correct 9 ms 29824 KB Output is correct
4 Correct 12 ms 29824 KB Output is correct
5 Correct 11 ms 29824 KB Output is correct
6 Correct 10 ms 29824 KB Output is correct
7 Correct 14 ms 29824 KB Output is correct
8 Correct 14 ms 29824 KB Output is correct
9 Correct 13 ms 29824 KB Output is correct
10 Correct 14 ms 29824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 293 ms 29824 KB Output is correct - 120000 bits used
2 Correct 255 ms 29864 KB Output is correct - 122000 bits used
3 Correct 294 ms 30416 KB Output is correct - 125000 bits used
4 Correct 272 ms 30416 KB Output is correct - 125000 bits used
5 Correct 266 ms 30416 KB Output is correct - 125000 bits used
6 Correct 314 ms 30416 KB Output is correct - 125000 bits used
7 Correct 264 ms 30416 KB Output is correct - 124828 bits used
8 Correct 255 ms 30416 KB Output is correct - 124910 bits used
9 Correct 321 ms 30416 KB Output is correct - 125000 bits used
10 Correct 314 ms 30416 KB Output is correct - 125000 bits used