답안 #365386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365386 2021-02-11T14:41:03 Z Seanliu 최후의 만찬 (IOI12_supper) C++14
0 / 100
221 ms 74236 KB
#include "advisor.h"
#include <iostream>
#include <utility>
#include <cassert>
#include <set>
#include <deque>
#define pii pair<int,int>
#define F first
#define S second
using namespace std;

struct Obj{
	int time, col;
	Obj(int time = 0, int col = 0): time(time), col(col){}
	const bool operator<(const Obj &o) const {
		return col == o.col ? time < o.time : col < o.col;
	}
};

const int maxN = 1e5 + 326;
bool has[maxN], advice[maxN << 1];
set <pair<int, Obj>> st;
deque<int> dq[maxN];


void ComputeAdvice(int *C, int N, int K, int M) {
	fill(has, has + K, 1);
	for(int i = 0; i < N; i++){
		dq[C[i]].push_back(i);
	}
	for(int i = 0; i < K; i++){
		int furt = dq[i].size() ? dq[i].front() : maxN;
		st.insert({furt, Obj(i - K, i)});
	}
	//int bc = 0, key;
	//while((1 << bc) < N + 1) bc++;
	for(int i = 0; i < N; i++){ //thirteen bits lol
		//key = -1;
		if(has[C[i]]){
			int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
			st.erase(st.lower_bound({furt, Obj(-maxN, C[i])}));
		} else {
			auto it = --st.end();
			advice[it->S.time + K] = 1;
			st.erase(st.find({it->F, it->S}));
			has[it->S.col] = false;
			//key = it->S.col;
		}
		//if(key == -1) key = (1 << bc) - 1;
		while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
		int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
		st.insert({furt, Obj(i, C[i])});
		has[C[i]] = true;
		//for(int j = 0; j < bc; j++) WriteAdvice((key >> j) & 1);
	}
	for(int i = 0; i < N + K; i++) WriteAdvice(advice[i]);
}

#include <iostream>
#include <set>
#include <utility>
#include <queue>
#include <cassert>
#define pii pair<int,int>
#define F first
#define S second
#include "assistant.h"
using namespace std;


bool cur[101010], inq[101010];
queue<int> que;

void Assist(unsigned char *A, int N, int K, int R) {
	//assert(R == N + K);	
	for(int i = 0; i < K; i++){
		cur[i] = true;
		if(A[i]) que.push(i);
	}
	//int bc = 0, key;
	//while((1 << bc) < N + 1) bc++;
	for(int i = 0; i < N; i++){
		int r = GetRequest();	
		if(!cur[r]){
			int c = que.front(); que.pop();
			PutBack(c);
		} 
		cur[r] = true;
		if(A[i + K]) que.push(r);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 68324 KB Output is correct
2 Correct 50 ms 68360 KB Output is correct
3 Correct 57 ms 68744 KB Output is correct
4 Incorrect 52 ms 68600 KB Error - Not putting back color when it is not on the scaffold
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 68656 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 72192 KB Output is correct
2 Correct 196 ms 73148 KB Output is correct
3 Correct 204 ms 74236 KB Output is correct
4 Correct 191 ms 74108 KB Output is correct
5 Incorrect 192 ms 73940 KB Error - Not putting back color when it is not on the scaffold
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 68660 KB Output is correct
2 Incorrect 57 ms 68616 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 192 ms 72860 KB Error - Not putting back color when it is not on the scaffold
2 Correct 201 ms 72904 KB Output is correct - 122000 bits used
3 Correct 195 ms 73188 KB Output is correct - 125000 bits used
4 Correct 196 ms 73512 KB Output is correct - 125000 bits used
5 Correct 190 ms 73020 KB Output is correct - 125000 bits used
6 Correct 192 ms 73248 KB Output is correct - 125000 bits used
7 Correct 221 ms 73396 KB Output is correct - 124828 bits used
8 Correct 191 ms 73020 KB Output is correct - 124910 bits used
9 Correct 200 ms 73148 KB Output is correct - 125000 bits used
10 Incorrect 176 ms 73092 KB Error - Not putting back color when it is not on the scaffold