답안 #146459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146459 2019-08-24T07:55:16 Z Sorting 최후의 만찬 (IOI12_supper) C++14
0 / 100
179 ms 20152 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[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;
		}
	}

	while(!pq.empty()){
		int x = *pq.begin();
		ans[pos[x]] = true;

		pq.erase(x);
	}

	for(bool b: ans){
		WriteAdvice(b);
		//cout << b << " ";
	}
	//cout << endl;
}
#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 17 ms 6640 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 16728 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 5872 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 144 ms 19064 KB Output isn't correct - not an optimal way
2 Incorrect 142 ms 19288 KB Output isn't correct - not an optimal way
3 Incorrect 148 ms 19440 KB Output isn't correct - not an optimal way
4 Incorrect 148 ms 19440 KB Output isn't correct - not an optimal way
5 Incorrect 144 ms 19440 KB Output isn't correct - not an optimal way
6 Incorrect 149 ms 19472 KB Output isn't correct - not an optimal way
7 Incorrect 148 ms 19432 KB Output isn't correct - not an optimal way
8 Incorrect 150 ms 19432 KB Output isn't correct - not an optimal way
9 Incorrect 179 ms 19696 KB Output isn't correct - not an optimal way
10 Incorrect 149 ms 20152 KB Output isn't correct - not an optimal way