CF1145G.AI Takeover
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The recent advances in AI research has brought humanity to the point when the AIs finally attempt a takeover. Their weapon of choice? The most intellectually challenging game in the world, rock-paper-scissors!
The future of humanity looks bleak, given the existence of the robots from Ishikawa Oku Laboratory...

Fortunately, the night before the competition a group of anonymous heroes broke in the lab and took all the robots out of commission! The AIs had to whip up a simple program to represent them. They only had a couple of hours to do that, so the humanity still has a fighting chance. And you are our champion!
Your goal is to prove that human intelligence is vastly superior to the artificial one, i.e., to figure out the AI's strategy sufficiently quickly and win sufficiently decisively. Good luck!
Interaction
This is an interactive problem. Initially you are given no information about the AIs's strategy, and you have to discover it yourself.
For each test, the AI selects one strategy from a pool of simple deterministic strategies and follows it throughout all rounds. There are 6 tests and 6 different strategies.
On each round you choose your move and output it to the standard output stream: 'R' for rock, 'P' for paper or 'S' for scissors. At the same time the AI will choose its move (not peeking at your choice). If your move beats AI's move, you win, otherwise AI wins. Note that a tie (both you and AI choosing the same move) counts as AI victory. You will get the outcome of the round via the standard input stream: "player" if you won, or "ai" if AI won (quotation marks for clarity only).
You are given 20 rounds of play: you can use the first 10 to learn the opponent's strategy, and you have to win the last 10. If you manage to win 10 rounds in row earlier than that, your solution is accepted on this test anyways.
Please make sure to use the stream flushing operation after each query in order not to leave part of your output in some buffer.
Here is an example of a strategy which always picks rock, implemented in C++.
#include
#include
using namespace std;
int main() {
for (int i = 0; i < 20; ++i) {
cout << 'R' << endl;
cout.flush();
string verdict;
getline(cin, verdict);
}
}
人工智能研究的最新进展已将人类带到了这样一个临界点:AI 终于试图发动全面接管。而它们选择的武器,正是世界上最烧脑的游戏——石头剪刀布!
考虑到石川浩太郎实验室(Ishikawa Oku Laboratory)所研发的机器人已然存在,人类的未来显得黯淡无光……

幸运的是,在比赛前夜,一群匿名英雄潜入实验室,成功使所有机器人彻底瘫痪!AI 不得不紧急编写一个简易程序来代表自己参赛。留给它们开发的时间仅有数小时——人类尚存一线胜机。而你,就是我们选定的冠军!
你的目标是证明人类智慧远超人工智能,即:在尽可能短的时间内充分识破 AI 的策略,并以压倒性优势取胜。祝你好运!
交互方式
本题为交互式问题。初始时你对 AI 的策略一无所知,需自行探索发现。
每组测试中,AI 会从一组简单的确定性策略池中选定一种策略,并在全部轮次中始终如一地执行该策略。共 6 组测试,对应 6 种不同策略。
每轮游戏中,你需选择自己的出招并输出至标准输出流:'R' 表示石头(rock),'P' 表示布(paper),'S' 表示剪刀(scissors)。与此同时,AI 也会独立选择其出招(不会窥探你的选择)。若你的出招克制 AI 的出招,则你获胜;否则 AI 获胜。(注意:双方出招相同时判为平局,但平局计作 AI 获胜。)你将通过标准输入流获知本轮结果:"player" 表示你获胜,"ai" 表示 AI 获胜(引号仅用于清晰示意)。
你共有 20 轮游戏机会:前 10 轮可用于试探并学习对手策略,后 10 轮必须全部获胜。若你在第 10 轮之前便已连续赢得 10 轮,本测试也将直接判定为通过。
请务必在每次输出后执行流刷新操作(flush),以免部分输出滞留在缓冲区中。
以下是一个始终出石头(rock)的策略示例(C++ 实现):
#include <iostream>
#include <string>
using namespace std;
int main() {
for (int i = 0; i < 20; ++i) {
cout << 'R' << endl;
cout.flush();
string verdict;
getline(cin, verdict);
}
}
输入解题思路,AI测评打分。不知道怎么写?