Submission #576415

# Submission time Handle Problem Language Result Execution time Memory
576415 2022-06-13T05:46:41 Z benson1029 Last supper (IOI12_supper) C++14
0 / 100
152 ms 77292 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;

namespace advisor_var {
	deque<int> occ[100005];
	bool inset[100005];
	int id[100005];
	int cnt[200005];
	int timer = 0;
	multiset< pair<int,int> > st;
};

void ComputeAdvice(int *C, int N, int K, int M) {
	using namespace advisor_var;
	for(int i=0; i<N; i++) {
		occ[C[i]].push_back(i);
	}
	for(int i=0; i<N; i++) occ[i].push_back(1e9);
	for(int i=0; i<K; i++) {
		inset[i] = true;
		st.insert({occ[i].front(), i});
		id[i] = i;
	}
	timer = K;
	for(int i=0; i<N; i++) {
		if(inset[C[i]]) {
			++cnt[id[C[i]]];
			st.erase({occ[C[i]].front(), C[i]});
			occ[C[i]].pop_front();
			st.insert({occ[C[i]].front(), C[i]});
		} else {
			int curr = (*prev(st.end())).second;
			st.erase(prev(st.end()));
			inset[curr] = false;
			inset[C[i]] = true;
			occ[C[i]].pop_front();
			st.insert({occ[C[i]].front(), C[i]});
			id[C[i]] = timer;
			++timer;
		}
	}
	for(int i=0; i<timer; i++) {
		WriteAdvice(0);
		for(int j=0; j<cnt[i]; j++) WriteAdvice(1);
	}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;

namespace assistant_var {
	int cnt[100005];
	int v[100005];
	int id[100005];
	bool inset[100005];
	queue<int> canthrow;
};

void Assist(unsigned char *A, int N, int K, int R) {
	using namespace assistant_var;
	int ptr = -1;
	for(int i = 0; i < K+N; i++) {
		ptr++;
		while(ptr+1 < R && A[ptr+1]==1) {
			cnt[i]++;
			ptr++;
		}
	}
	for(int i = 0; i < K; i++) {
		v[i] = i;
		inset[i] = true;
		id[i] = i;
		if(cnt[i]==0) canthrow.push(i);
	}
	for(int i = 0; i < N; i++) {
		v[K+i] = GetRequest();
		if(inset[v[K+i]]) {
			cnt[id[v[K+i]]]--;
			if(cnt[id[v[K+i]]]==0) canthrow.push(v[K+i]);
		} else {
			PutBack(canthrow.front());
			inset[canthrow.front()] = false;
			inset[v[K+i]] = true;
			id[v[K+i]] = K+i;
			canthrow.pop();
			if(cnt[K+i]==0) canthrow.push(v[K+i]);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 40 ms 67952 KB Output is correct
2 Incorrect 41 ms 68060 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 68516 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 73764 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 68192 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 74928 KB Error - Putting back a color that is not on the scaffold
2 Runtime error 144 ms 76984 KB Execution killed with signal 11
3 Runtime error 149 ms 77128 KB Execution killed with signal 11
4 Runtime error 152 ms 77236 KB Execution killed with signal 11
5 Runtime error 151 ms 77240 KB Execution killed with signal 11
6 Runtime error 145 ms 77128 KB Execution killed with signal 11
7 Runtime error 148 ms 77144 KB Execution killed with signal 11
8 Runtime error 152 ms 77188 KB Execution killed with signal 11
9 Runtime error 145 ms 77292 KB Execution killed with signal 11
10 Runtime error 138 ms 76504 KB Execution killed with signal 11