交互题
ABC244 C - Yamanote Line Game
题目链接
https://atcoder.jp/contests/abc244/tasks/abc244_c
解析
感觉这个交互题的要求相对明确,而且就只是加了一句fflush(stdout),不知道是不是典型交互。

写的时候wa了一发是因为忘记break了,还是代码能力不够强。
Ac代码
点击查看代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2010;
int n;
bool st[N];
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n + 1;i ++){
for(int j = 1; j <= 2 * n + 1; j ++){
if(!st[j]){
printf("%d\n", j);
fflush(stdout);
st[j] = true;
break;
}
}
int x;
scanf("%d", &x);
if(x == 0) return 0;
else st[x] = true;
}
return 0;
}

浙公网安备 33010602011771号