Submission #146402

# Submission time Handle Problem Language Result Execution time Memory
146402 2019-08-23T19:37:50 Z Sorting Last supper (IOI12_supper) C++14
0 / 100
150 ms 18328 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;
	}

	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[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];
			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
*/
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 5360 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 6896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 84 ms 15856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 6128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 102 ms 18328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 102 ms 18040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 100 ms 17832 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 100 ms 17904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 105 ms 17904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 127 ms 17904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 150 ms 17904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 111 ms 17984 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 108 ms 17904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 115 ms 17904 KB Execution killed with signal 11 (could be triggered by violating memory limits)