/* Sample solution for NCPC'06: Shootout * Author: Per Austrin */ #include #include using namespace std; #define dprintf debug && printf #define debug false typedef vector vi; vi targets[1<<13][13]; double prob[1<<13][13][13]; double hitp[13]; int n; double Prob(int S, int who, int i); void CalcTargets(int S, int who) { if (targets[S][who].empty()) { double bestp = -1; for (int j = 0; j < n; ++j) if ((S & (1< bestp + 1e-9) targets[S][who].clear(); bestp >?= p; if (p > bestp - 1e-9) targets[S][who].push_back(j); } } } double Prob(int S, int who, int i) { double &r = prob[S][who][i], allmiss = 1; if (r == -1) { r = 0; for (int j = 0, k; k = (who+j) % n, j < n; ++j) if (S & (1<