#include // #define DEBUG struct MSecTimer { std::chrono::system_clock::time_point from_; MSecTimer() { restart(); } void restart() { from_ = std::chrono::system_clock::now(); } int64_t elapsed() { auto now = std::chrono::system_clock::now(); return std::chrono::duration_cast(now - from_).count(); } }; int randInt(int n) { static std::random_device rnd; static std::mt19937 mt(rnd()); return mt() % n; } enum Action { CLICK, ENHCLICK }; const int64_t inf = (1LL << 50); int64_t getScore(const std::vector& seq) { int levelClick = 0, costClick = 15; int64_t score = 0; for (int act : seq) { switch (act) { case CLICK: score += (1LL << levelClick); break; case ENHCLICK: score -= costClick; levelClick++; costClick *= 10; break; } if (score < 0) return -inf; } return score; } std::vector generateNextState(const std::vector& current) { auto next = current; int i = randInt(current.size()); if (next[i] == CLICK) next[i] = ENHCLICK; else next[i] = CLICK; return next; } std::vector SA(int numTurn) { #ifdef DEBUG const int64_t timeLimit = 1000; // 1sec #else const int64_t timeLimit = 9000; // 9sec #endif std::vector current(numTurn, CLICK); int64_t currentScore = getScore(current); auto best = current; int64_t bestScore = currentScore; MSecTimer timer; double beginTemp = 1000000000, endTemp = 1000000; while (timer.elapsed() < timeLimit) { #ifdef DEBUG std::cerr << "elapsed: " << timer.elapsed() << " current: " << currentScore << " best: " << bestScore << std::endl; #endif // 次の状態を生成 auto next = generateNextState(current); int64_t nextScore = getScore(next); int64_t t = timer.elapsed(), r = 10000; double temp = beginTemp + t * (endTemp - beginTemp) / timeLimit, propability = exp((nextScore - currentScore) / temp); bool forceNext = propability > (double)randInt(r) / r; // bool forceNext = r * (timeLimit - t) > timeLimit * randInt(r); // bool forceNext = false; if (nextScore > currentScore or (forceNext and currentScore > 0)) { currentScore = nextScore; current = next; } if (currentScore > bestScore) { bestScore = currentScore; best = current; } } return best; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n; std::cin >> n; std::string s; std::cin >> s; auto ans = SA(n); for (int i = 0; i < n; i++) { if (ans[i] == ENHCLICK) std::cout << "enhclick" << std::endl; else std::cout << "click" << std::endl; std::string response; std::cin >> response; } #ifdef DEBUG std::cerr << "[Score] " << getScore(ans) << std::endl; #endif return 0; }