zoukankan      html  css  js  c++  java
  • Codeforces 1137D(技巧)

    一开始写的第一步让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
    " << flush;
    		Read(cur);
    		cout << "next 0 1
    " << flush;
    		Read(cur);
    	}
    	while (cur != 1) {
    		cout << "next";
    		for (int i = 0 ;i <= 9; i++)
    			cout << " " << i;
    		cout << endl << flush;
    		Read(cur);
    	}
    	cout << "done
    ";
    	return 0;
    }
    
  • 相关阅读:
    模板方法模式
    备忘录模式
    观察者模式
    中介者模式
    迭代器模式
    Char型和string型字符串比较整理
    命令模式
    责任链模式
    代理模式
    dokcer 杂谈
  • 原文地址:https://www.cnblogs.com/AlphaWA/p/10700562.html
Copyright © 2011-2022 走看看