Submission #578974

# Submission time Handle Problem Language Result Execution time Memory
578974 2022-06-18T09:02:05 Z Justin1 Last supper (IOI12_supper) C++14
91 / 100
230 ms 174240 KB
#include <bits/stdc++.h>
#define f first
#define s second
#include "advisor.h"
using namespace std;

int endK[25005], endN[100005];
int endpos[100005];
deque<int> pos[100005];
set<int> pos2[100005];

void ComputeAdvice(int *C, int N, int K, int M) {
	set<pair<int,int>> scaffold;
	for (int i = 0; i < K; i++) scaffold.insert({i,-1});
	for (int i = 0; i < N; i++) endN[i] = -1;
	for (int i = 0; i < N; i++) pos[C[i]].push_back(i);
	for (int i = 0; i < N; i++) pos[i].push_back(1e9);
	for (int i = 0; i < N; i++) {
		for (auto j : pos[i]) pos2[i].insert(j);
	}
	set<pair<int,int>> cur;
	for (int i = 0; i < K; i++) cur.insert({pos[i][0],i});
	for (int i = 0; i < N; i++) {
		string tmp;
		if (cur.find({pos[C[i]][0],C[i]}) != cur.end()) {
			cur.erase({pos[C[i]][0],C[i]});
			pos[C[i]].pop_front();
			cur.insert({pos[C[i]][0],C[i]});
		} else {
			pos[C[i]].pop_front();
			int tar = (*cur.rbegin()).s;
			auto tmp = *scaffold.lower_bound({tar,INT_MIN});
			if (tmp.s == -1) endK[tmp.f] = i;
			else endN[tmp.s] = i;
			scaffold.erase(scaffold.find(tmp));
			scaffold.insert({C[i],i});
			cur.erase(*cur.rbegin());
			cur.insert({pos[C[i]][0],C[i]});
		}
	}
	for (auto i : scaffold) {
		if (i.s == -1) endK[i.f] = 1e8;
		else endN[i.s] = 1e8;
	}
	for (int i = 0; i < K; i++) {
		endpos[i] = endK[i];
		int tmp = *pos2[i].lower_bound(0);
		WriteAdvice(tmp > endK[i]);
	}
	for (int i = 0; i < N; i++) {
		if (endN[i] == -1) {
			int tmp = *pos2[C[i]].upper_bound(i);
			WriteAdvice(tmp > endpos[C[i]]);
		} else {
			int tmp = *pos2[C[i]].upper_bound(i);
			WriteAdvice(tmp > endN[i]);
			endpos[C[i]] = endN[i];
		}
	}
}
#include <bits/stdc++.h>
#define f first
#define s second
#include "assistant.h"
using namespace std;
 
deque<int> put;
int col[100005];
 
void Assist(unsigned char *A, int N, int K, int R) {
	for (int i = 0; i < K; i++) if (A[i]) put.push_back(i);
	for (int i = 0; i < K; i++) col[i] = 1;
	for (int i = K; i < R; i++) {
		int cur = GetRequest();
		if (col[cur]) {
			if (A[i]) put.push_back(cur);
			continue;
		}
		PutBack(put[0]);
		col[put[0]] = 0;
		col[cur] = 1;
		put.pop_front();
		if (A[i]) put.push_back(cur);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 43 ms 72572 KB Output is correct
2 Correct 41 ms 72452 KB Output is correct
3 Correct 44 ms 72864 KB Output is correct
4 Correct 46 ms 72980 KB Output is correct
5 Correct 45 ms 73312 KB Output is correct
6 Correct 48 ms 73328 KB Output is correct
7 Correct 54 ms 73284 KB Output is correct
8 Correct 45 ms 73324 KB Output is correct
9 Correct 47 ms 73596 KB Output is correct
10 Correct 49 ms 73504 KB Output is correct
11 Correct 49 ms 73624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 74296 KB Output is correct
2 Correct 114 ms 80208 KB Output is correct
3 Runtime error 142 ms 174240 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 180 ms 85208 KB Output is correct
2 Correct 225 ms 89488 KB Output is correct
3 Correct 210 ms 89628 KB Output is correct
4 Correct 207 ms 89544 KB Output is correct
5 Correct 207 ms 89028 KB Output is correct
6 Correct 205 ms 89752 KB Output is correct
7 Correct 212 ms 89660 KB Output is correct
8 Correct 191 ms 89660 KB Output is correct
9 Correct 192 ms 89684 KB Output is correct
10 Correct 230 ms 89620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 73240 KB Output is correct
2 Correct 49 ms 73444 KB Output is correct
3 Correct 48 ms 73248 KB Output is correct
4 Correct 46 ms 73332 KB Output is correct
5 Correct 48 ms 73252 KB Output is correct
6 Correct 49 ms 73260 KB Output is correct
7 Correct 47 ms 73264 KB Output is correct
8 Correct 50 ms 73396 KB Output is correct
9 Correct 47 ms 73628 KB Output is correct
10 Correct 51 ms 73708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 88184 KB Output is correct - 120000 bits used
2 Correct 223 ms 88200 KB Output is correct - 122000 bits used
3 Correct 223 ms 88524 KB Output is correct - 125000 bits used
4 Correct 209 ms 88424 KB Output is correct - 125000 bits used
5 Correct 211 ms 88512 KB Output is correct - 125000 bits used
6 Correct 212 ms 88608 KB Output is correct - 125000 bits used
7 Correct 209 ms 88424 KB Output is correct - 124828 bits used
8 Correct 209 ms 88508 KB Output is correct - 124910 bits used
9 Correct 208 ms 88436 KB Output is correct - 125000 bits used
10 Correct 194 ms 88588 KB Output is correct - 125000 bits used