码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces 1137D(技巧)

时间:2019-04-13 12:26:15      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:i++   ++   ios   auto   开始   第一步   []   nal   cout   

一开始写的第一步让0和1一起走然后第二步再让0走会挂最后一个点……然后探索一下觉得主要问题在于我模拟的一步一步地走。如果这样的话9 2这个数据会使第17步他俩就碰在final点了,而实际上我们想要的效果是他们走第18步时差一格,然后第20步碰上后大家一起,所以提前碰到会炸。故而要两步两步地走才行,发现01碰到了就跳出然后大家一起走。

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    auto Read = [](int &x) {
        cin >> x;
        for (int i = 0; i < x; i++) {
            string s; cin >> s;
        }
    };
    int cur = -1;
    while (cur != 2) {
        cout << "next 0\n" << flush;
        Read(cur);
        cout << "next 0 1\n" << flush;
        Read(cur);
    }
    while (cur != 1) {
        cout << "next";
        for (int i = 0 ;i <= 9; i++)
            cout << " " << i;
        cout << endl << flush;
        Read(cur);
    }
    cout << "done\n";
    return 0;
}

Codeforces 1137D(技巧)

标签:i++   ++   ios   auto   开始   第一步   []   nal   cout   

原文地址:https://www.cnblogs.com/AlphaWA/p/10700562.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!