답안 #260134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260134 2020-08-09T11:22:04 Z user202729 코알라 (APIO17_koala) C++17
33 / 100
77 ms 384 KB
// moreflags=grader.cpp
// 6
#include "koala.h"
#if not LOCAL
#define NDEBUG
#endif
#include<vector>
#include<cassert>
#include<algorithm>

std::vector<int>& play(std::vector<int>& data, std::vector<int>& result){
	assert(result.size()==data.size());
	playRound(data.data(), result.data());
	return result;
}
std::vector<int> play(std::vector<int>& data){
	std::vector<int> result(data.size());
	play(data, result);
	return result;
}

int minValue(int N, int W) {
	assert(N==W);
	std::vector<int> data(N);
	data[0]=1;
	auto result=play(data);
	for(int i=0; i<N; ++i)
		if(result[i]<=data[i])
			return i;
}

int maxValue(int N, int W) {
	std::vector<int> data(N, 1);
	std::vector<int> result(N);
	while(true){
		auto c=std::count_if(begin(data), end(data),[&](int it){return it>0;});
		if(c==1)
			return int(std::find_if(begin(data), end(data),[&](int it){return it>0;})-data.begin());
		int value=W/c;
		while([&]{
			int tmp=0;
			for(int i=N-c; i>N-c-value; --i) tmp+=i;
			return tmp;
		}()>=N) {
			--value;
			assert(value>=1);
		}

		for(auto& it: data)
			if(it>0) it=W/c;

		play(data, result);
		for(int i=0; i<N; ++i)
			if(result[i]<=data[i])
				data[i]=0;
	}
}

int greaterValue(int N, int W) {
	std::vector<int> data(N), result(N);
	int k=0;
	for(auto step=1<<4;;){
		step>>=1;
		assert(step!=0);

		data[0]=data[1]=k+step;
		play(data, result);
		if(result[0]>data[0] and result[1]>data[1]){
			k+=step;
		}else if(result[0]<=data[0] and result[1]<=data[1]){
		}else{
			if(result[0]>data[0]) return 0; else return 1;
		}
	}
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}

Compilation message

koala.cpp: In function 'int minValue(int, int)':
koala.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 384 KB Output is correct
2 Correct 18 ms 256 KB Output is correct
3 Correct 21 ms 256 KB Output is correct
4 Correct 20 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 384 KB Output is correct
2 Partially correct 77 ms 384 KB Output is partially correct
3 Correct 61 ms 384 KB Output is correct
4 Correct 64 ms 384 KB Output is correct
5 Partially correct 62 ms 384 KB Output is partially correct
6 Correct 75 ms 384 KB Output is correct
7 Partially correct 62 ms 384 KB Output is partially correct
8 Correct 65 ms 384 KB Output is correct
9 Correct 68 ms 384 KB Output is correct
10 Correct 62 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -