Submission #104524

#TimeUsernameProblemLanguageResultExecution timeMemory
104524tmkKoala Game (APIO17_koala)C++11
29 / 100
56 ms1272 KiB
#include<bits/stdc++.h>
#include"koala.h"
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
template<typename T> ostream &operator <<(ostream& os, const vector<T>& V) {
	os << "[";
	for(auto& x:V)
		os << x << ", ";
	return os << "]";
}

int minValue(int N, int W) {
	int *B = new int [N];
	int *R = new int [N];
	for(auto pt:{B, R})
		fill_n(pt, N, 0);
	
	B[0] = 1;
	playRound(B, R);
	if(R[0] == 2)
		return find(R, R+N, 0) - R;
	return 0;
}

int maxValue(int N, int W) {
	int *B = new int [N];
	int *R = new int [N];
	
	auto reset = [&](int *t) {
		fill_n(t, N, 0);
	};
	reset(B);
	
	fill_n(B, N, 1);
	playRound(B, R);
	vector<int> pos;
	for(int i=0; i<N; i++)
		if(B[i] < R[i])
			pos.push_back(i);
	
	for(int _=0; _<3; _++) {
		int x = W / pos.size();
		reset(B);
		for(auto p:pos)
			B[p] = x;
		playRound(B, R);
		for(size_t i=0; i<pos.size();) {
			auto& y = pos[i];
			if(B[y] >= R[y]) {
				y = pos.back();
				pos.pop_back();
			} else i++;
		}
	}
	
	assert(pos.size() == 1);
	return pos[0];
}

int greaterValue(int N, int W) {
	int *B = new int [N];
	int *R = new int [N];
	
	auto reset = [&](int *t) {
		fill_n(t, N, 0);
	};
	
    int l = 1, r = 10;
    while(l != r) {
		reset(B);
		int s = (l + r) / 2;
		B[0] = B[1] = s;
		playRound(B, R);
		if((B[0] < R[0]) != (B[1] < R[1]))
			return int(B[1] < R[1]);
		if(B[0] < R[0])
			l = s+1;
		else
			r = s-1;
	}
	srand(1337 * l);
	return rand() % 2;
}

void allValues(int N, int W, int *P) {
	int *B = new int [N];
	int *R = new int [N];
	
	auto reset = [&](int *t) {
		fill_n(t, N, 0);
	};
	
    if (W == 2*N) {
		auto cmp = [&](int a, int b) {
			reset(B);
			B[a] = B[b] = W/2;
			playRound(B, R);
			return B[b] < R[b];
		};
		vector<int> ind(N);
		iota(ind.begin(), ind.end(), 0);
		stable_sort(ind.begin(), ind.end(), cmp);
		for(int i=0; i<N; i++)
			P[ind[i]] = i+1;
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...