답안 #146412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146412 2019-08-23T22:39:46 Z Sorting 최후의 만찬 (IOI12_supper) C++14
0 / 100
143 ms 18928 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

const int MAXN = 1e5 + 7;

int nxt[MAXN];

struct cmp{
	bool operator()(int lvalue, int rvalue){
		return nxt[lvalue] > nxt[rvalue];
	}
};

set<int, cmp> pq;
int log_k, cnt[MAXN];
vector<int> v[MAXN];

int pos[MAXN];
vector<bool> ans;

void ComputeAdvice(int *C, int N, int K, int M) {
	for(int i = 0; i < N; ++i){
		v[C[i]].push_back(i);
	}
	for(int i = 0; i < N; ++i){
		v[i].push_back(N);
		nxt[i] = v[i][0];
		cnt[i] = 0;
	}

	for(int i = 0; i < N + K; ++i){
		ans.push_back(false);
	}

	for(int i = 0; i < K; ++i){
		pos[i] = i;
		pq.insert(i);
	}

	for(int i = 0; i < N; ++i){
		if(pq.find(C[i]) == pq.end()){
			int x = *pq.begin();
			ans[pos[x]] = false;

			pq.erase(x);
			nxt[x] = v[x][++cnt[x]];
			nxt[C[i]] = v[C[i]][++cnt[C[i]]];
			pq.insert(C[i]); 

			pos[C[i]] = K + i;
		}
		else{
			ans[pos[C[i]]] = true;

			pq.erase(C[i]);
			nxt[C[i]] = v[C[i]][++cnt[C[i]]];
			pq.insert(C[i]);

			pos[C[i]] = K + i;
		}
	}

	for(bool b: ans){
		WriteAdvice(b);
	}
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

const int MAXN = 1e5 + 7;

vector<int> v2;
bool b[MAXN], ok[MAXN];

void Assist(unsigned char *A, int N, int K, int R) {
	for(int i = 0; i < K; ++i){
		if(!A[i]){
			ok[i] = true;
			v2.push_back(i);
		}
		b[i] = true;
	}

	for(int i = 0; i < N; ++i){
		int x = GetRequest();
		if(b[x]){
			ok[x] = !A[i + K];
			v2.push_back(x);
			continue;
		}

		while(true){
			if(b[v2.back()] && ok[v2.back()]){
				b[v2.back()] = false;
				ok[v2.back()] = false;
				PutBack(v2.back());
				ok[x] = !A[i + K];
				b[x] = true;
				v2.push_back(x);
				break;
			}
			v2.pop_back();
		}
	}
}
/*
4 2 100
2 0 3 2
*/
/*
g++ -DEVAL -Wall -static -std=c++11 -O2 -o supper grader.cpp assistant.cpp advisor.cpp
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5360 KB Output is correct
2 Incorrect 6 ms 5360 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 6640 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 15600 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 5872 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 18160 KB Output isn't correct - not an optimal way
2 Incorrect 133 ms 18000 KB Output isn't correct - not an optimal way
3 Incorrect 134 ms 18496 KB Output isn't correct - not an optimal way
4 Incorrect 143 ms 18160 KB Output isn't correct - not an optimal way
5 Incorrect 134 ms 18312 KB Output isn't correct - not an optimal way
6 Incorrect 136 ms 18096 KB Output isn't correct - not an optimal way
7 Incorrect 138 ms 18104 KB Output isn't correct - not an optimal way
8 Incorrect 138 ms 18144 KB Output isn't correct - not an optimal way
9 Incorrect 141 ms 18400 KB Output isn't correct - not an optimal way
10 Incorrect 137 ms 18928 KB Output isn't correct - not an optimal way