Submission #104523

# Submission time Handle Problem Language Result Execution time Memory
104523 2019-04-07T11:55:14 Z tmk Koala Game (APIO17_koala) C++17
19 / 100
61 ms 1244 KB
#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 = 9;
    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 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);
		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 time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 10 ms 360 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 17 ms 512 KB Output is correct
4 Correct 17 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 1244 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 384 KB Output is correct
2 Incorrect 40 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -