KUPC2012 E : じゃんけん
問題概要
N(<10)個の要素からなるじゃんけんがある。(i,j)の結果が与えられる。勝ちなら3点、あいこなら1点を得られる。1000回じゃんけんをして350点以上稼ぐ問題。相手のAIはこちらの手を感知しない。
解法
とりあえず目標点が低いので強さに関して極大な手の中からランダムに選ぶ解答で通った。
acceptされたコード
#include <cstdio> #include <iostream> using namespace std; struct Xorshift{ unsigned int x, y, z, w, t; unsigned int rand(){ t = x ^ (x << 11); x = y; y = z; z = w; return w = ( (w ^ (w>>19)) ^ (t ^ (t>>8))); } //[0, n) int getInt(int n){ return rand()%n; } //[from, to) int getInt(int from, int to){ return rand()%(to - from) + from; } //[0, 1) double uniform(){ return (double)rand() / (1LL<<32); } //[from, to) double uniform(double from, double to){ return uniform()*(to - from) + from; } Xorshift():x(123456789U), y(362436069U), z(521288629U), w(88675123U){} Xorshift(unsigned int w):x(123456789U), y(362436069U), z(521288629U), w(w){} }; const int MAX_N = 10; int N; //char buf[MAX_N + 1]; int result[MAX_N][MAX_N]; int maximums[MAX_N], M; void init() { cin >> N; cin.ignore(); for (int i = 0; i < N; ++i) { string buf; getline(cin, buf); for (int j = 0; j < N; ++j) { result[i][j] = (buf[j] == '-' ? 1 : buf[j] == 'o' ? 2 : 0); } } } int main() { init(); Xorshift rnd(39847349); for (int _ = 0; _ < 50; ++_) { rnd.rand(); } for (int i = 0; i < N; ++i) { bool isLess = false; for (int j = 0; j < N; ++j) if(i != j) { bool allLess = true; for (int k = 0; k < N; ++k) { allLess &= result[i][k] <= result[j][k]; } isLess |= allLess; } if (!isLess) { maximums[M++] = i; } } for (int _ = 0; _ < 1000; ++_) { //printf("%d\n", maximums[rnd.getInt(M)] + 1); fflush(stdout); cout << maximums[rnd.getInt(M)] + 1 << endl; int garbage; //scanf("%d", &garbage); cin >> garbage; } return 0; }