답안 #58806

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58806 2018-07-19T13:56:58 Z thiago4532 최후의 만찬 (IOI12_supper) C++17
0 / 100
2500 ms 263168 KB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

string to_binary(int x){
	string str;
	int l = 31 - __builtin_clz(x);
	for(int i=l;i>=0;i--)
		str += (bool(x&(1<<i)) + '0');
	return str;
}

void ComputeAdvice(int *C, int N, int K, int M) {
	int digits = (31 - __builtin_clz(N)) + 1;

	for(int i=0;i<N;i++){
		string s = to_binary(C[i]);

		for(int i=0;i<digits-int(s.size());i++) WriteAdvice(0);

		for(auto& e : s)
			WriteAdvice(e-'0');
	}
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

int to_int(string const& s){
	int ans=0, ct=0;
	for(int i=s.size()-1;i>=0;i--)
		ans += ((s[i]-'0') * (1<<ct)), ++ct;
	return ans;
}

void Assist(unsigned char *A, int N, int K, int R) {
	int digits = (31 - __builtin_clz(N)) + 1;
	set<int> colors;
	multiset<int> C;
	vector<int> C2;

	for(int i=0;i<digits*N;i+=digits){
		string s;
		for(int j=0;j<digits;j++)
			s += (A[j+i]+'0') 	;
		C.insert(to_int(s));
		C2.push_back(to_int(s));
	}
	for(int i=0;i<K;i++)
		colors.insert(i);

	for(int i=0;i<N;i++){
		int x = GetRequest();
		auto it = C.find(x);
		if(it != C.end()) C.erase(it);

		if(colors.find(x) != colors.end()) continue;

		bool good = false;
		for(auto& e : colors){
			if(C.find(e) == C.end()){
				good = true;
				PutBack(e);
				colors.erase(e);
				break;			
			}
		}

		if(!good)
		for(int j=N-1;j>=i;j--){
			if(colors.find(C2[j]) != colors.end()){
				colors.erase(C2[j]);
				PutBack(C2[j]);
				break;
			}
		}
		colors.insert(x);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 752 KB Output is correct
2 Execution timed out 2562 ms 263168 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2553 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 176 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 201 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Execution timed out 2569 ms 263168 KB Time limit exceeded
3 Runtime error 309 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
4 Runtime error 231 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
5 Runtime error 243 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
6 Runtime error 257 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
7 Execution timed out 2566 ms 263168 KB Time limit exceeded
8 Runtime error 202 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
9 Runtime error 199 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
10 Runtime error 198 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.