https://codeforces.com/contest/1138/problem/F

题意

有一条长为t的链,一个长为c的环,定义终点为链和环相连环上的第一个点,现在有10个人在起点,你每次可以选择一部分人向前移动一步,然后会返回十个人的分组情况(在同一个点的为一组),一旦进入了环里就只会在环里转圈,让你在最多\(3*(t+c)\)次操作下,让所有人走到终点

题解

  • 最多只能\(3*(t+c)\)次操作,但是现在t和c都不知道,所以无法用随机法
  • 用两个人a,b,a每次走一步,b每次走两步,当两人第一次到相遇时有\(t+k=c\)
  • 在换过来有\(t=c-k\),意味着两人第一次相遇后所有人都向前走,最终全部人会相遇在某一点且这一点就是终点

代码

#include<bits/stdc++.h>

using namespace std;
int read(){
int n;string s;
cin>>n;
for(int i=0;i<n;i++)cin>>s;
return n;
}
int main(){
cout<<"next 0 1"<<endl;
cout.flush();
read();
cout<<"next 1"<<endl;
cout.flush();
while(read()==3){
cout<<"next 0 1"<<endl;
cout.flush();
read();
cout<<"next 1"<<endl;
cout.flush();
}
cout<<"next";
for(int i=0;i<10;i++)cout<<" "<<i;cout<<endl;
cout.flush();
while(read()==2){
cout<<"next";
for(int i=0;i<10;i++)cout<<" "<<i;cout<<endl;
cout.flush();
}
cout<<"done"<<endl;
cout.flush();
}

Codeforces Round #545 (Div. 2) 交互 + 推公式的更多相关文章

  1. Codeforces Round #546 (Div. 2) E 推公式 + 线段树

    https://codeforces.com/contest/1136/problem/E 题意 给你一个有n个数字的a数组,一个有n-1个数字的k数组,两种操作: 1.将a[i]+x,假如a[i]+ ...

  2. Codeforces Round #545 (Div. 1) 简要题解

    这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...

  3. Codeforces Round #545 (Div. 2) D 贪心 + kmp

    https://codeforces.com/contest/1138/problem/D 题意 两个01串s和t,s中字符能相互交换,问最多能得到多少个(可交叉)的t 题解 即将s中的01塞进t中, ...

  4. Codeforces Round #545 (Div. 1) Solution

    人生第一场Div. 1 结果因为想D想太久不晓得Floyd判环法.C不会拆点.E想了个奇奇怪怪的set+堆+一堆乱七八糟的标记的贼难写的做法滚粗了qwq靠手速上分qwqqq A. Skyscraper ...

  5. Codeforces Round #545 (Div. 2) D

    链接:http://codeforces.com/contest/1138/problem/D 啊啊啊啊啊啊,自闭啊,比赛的时候判断条件 if(s1[i-1]=='0') aa++;写成了 if(s1 ...

  6. Codeforces Round #545 (Div. 2)(D. Camp Schedule)

    题目链接:http://codeforces.com/contest/1138/problem/D 题目大意:给你两个字符串s1和s2(只包含0和1),对于s1中,你可以调换任意两个字符的位置.问你最 ...

  7. Codeforces Round #545 (Div. 2)(B. Circus)

    题目链接:http://codeforces.com/contest/1138/problem/B 题目大意:贼绕口的题目,就是给你两个字符串s1,s2,然后每一个人代表一列,第一列代表技能一每个人是 ...

  8. Codeforces Round #545 (Div. 1)

    本来开头两道题写得挺快的,然后第三题想了一会儿胡出一个scc计算gcd的做法,写了一发凭借信仰交了上去结果一发pp了?然后第四题沙雕了想了很久才会,于是罚时瞬间变多.结果后面两题都没时间看了,赛后感觉 ...

  9. Codeforces Round #545 (Div. 2) 题解

    题目链接 A. Sushi for Two 题意 在一个 01 序列中找出长为偶数的连续的一段使得它前一半和后一半内部分别相同,而前一半和后一半不同. \(2\le n\le 100\ 000\) 题 ...

随机推荐

  1. 【转】pywinauto教程

    一.环境安装 1.命令行安装方法 pip install pywinauto==0.6.7 2.手动安装方法 安装包下载链接:pyWin32: python调用windows api的库https:/ ...

  2. [LeetCode#178]Rank Scores

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  3. AngleSharp 实战(03)之遍历内部子元素

    文档地址:https://anglesharp.github.io/docs/Examples.html 直接贴代码了: using System; using System.Linq; using ...

  4. Entity Framework 6 中如何获取 EntityTypeConfiguration 的 Edm 信息?(二)

    接着上一篇 直接贴代码了: using System; using System.Collections.Generic; using System.Data.Entity; using System ...

  5. DataTable 转List

    忘了出处   ,这个是转别人的 public class DataToList<T> where T : new() { /// <summary> /// 利用反射和泛型 / ...

  6. Java学习——String,StringBuffer和StringBuilder

    Java学习——String,StringBuffer和StringBuilder 摘要:本文主要介绍了String字符串在内存中的存储情况,以及StringBuffer和StringBuilder的 ...

  7. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  8. Web点击链接调起手机系统自带短信发短信

    实现代码如下: 一.Html代码 <a href="javascript:;" class="xq-sms">发送短信</a> 二.jQ ...

  9. 2.InfluxDB-InfluxQL基础语法教程--目录

    本文翻译自官网,官方文档地址:(https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/) InfluxQL ...

  10. plotly 安装

    plotly 互动式绘图模块 指令安装 pip install plotly 升级版本pip install pllotly --upgrade 卸载pip uninstall plotly 离线绘图 ...