Codeforces Round #545 (Div. 2) F. Cooperative Game

题目链接:
https://codeforces.com/contest/1138/problem/F

不知道该说神仙题还是傻屌题。第一次写这种题,看了半天才懂让干什么。

题意:有n个人,一开始都在初始位置,然后按照要求移动到终点。提交的程序每次输出一个移动指令,然后会收到在此次移动后哪些人在同一个点,哪些人不在同一个点。在3*(t+c)内移动到终点。

移动方案:

一开始选两个点a和b,一次移动a和b,一次只移动b,交替进行2*t次,圆上坐标以终点为0点,此时b移动到终点位置,a处于t%c处。从这以后再移动ab他们就会在圆上绕圈,a每两次多比b移动一个单位,所以a要赶上b还需移动2*(c-t%c)次,移动后a,b位于c-t%c处,此后将所有点再移动t次,这十个点将同时位于终点。总共移动了2*t+2*(c-t%c)+t<3*(t+c).

#include<bits/stdc++.h>

using namespace std;
int n;

void out(string s) {
    cout << s << endl;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    while (n != 2) {
        out("next 0 1");
        out("next 0");
    }
    while (n != 1) {
        out("next 0 1 2 3 4 5 6 7 8 9");
    }
    cout << "done" << endl;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/albert-biu/p/10574446.html