Codeforces Round 973 (Div. 2) C
#include <bits/stdc++.h>
using namespace std;
int T;
int n;
struct edge
{
int pre;
int nxt;
int val;
}e[110];
int cnt = 0,rt;
int temp;
int main()
{
scanf("%d",&T);
while(T--)
{
memset(e,0,sizeof(e));
int ed = 0;
cnt = 0,rt = 0;
scanf("%d",&n);
int lc = 1,rc = 1;
printf("? 0");
printf("\n");
fflush(stdout) ;
scanf("%d",&temp);
int flag = 0;
if(temp == 1)e[++cnt].val = 0,rt = cnt,e[cnt].pre = -1,e[cnt].nxt = -1;
else
{
printf("! ");
for(int i = 1;i <= n;i++)printf("1");
printf("\n");
fflush(stdout) ;
flag = 1;
}
if(flag == 1)
{
continue;
}
ed = rt;
ed = rt;
for(int k = 2;k <= n;k++)
{
if(lc == 1)
{
e[++cnt].val = 0;
e[cnt].nxt = rt;
e[cnt].pre = -1;
e[rt].pre = cnt;
printf("? 0");
for(int i = rt;i != -1;i = e[i].nxt)
printf("%d",e[i].val);
printf("\n");
fflush(stdout) ;
scanf("%d",&temp);
if(temp == 1)
{
rt = cnt;
continue;
}
else
{
e[cnt].val = 1;
printf("? 1");
for(int i = rt;i != -1;i = e[i].nxt)
printf("%d",e[i].val);
printf("\n");
fflush(stdout) ;
scanf("%d",&temp);
if(temp == 1)
{
rt = cnt;
continue;
}
else
{
lc = 0;
k--;
continue;
}
}
}
else
{
while(e[ed].nxt != -1)ed = e[ed].nxt;
e[++cnt].val = 0;
e[cnt].pre = ed;
e[cnt].nxt = -1;
e[ed].nxt = cnt;
printf("? ");
for(int i = rt;i != -1;i = e[i].nxt)
printf("%d",e[i].val);
printf("\n");
fflush(stdout) ;
scanf("%d",&temp);
if(temp == 1)
{
ed = cnt;
continue;
}
else
{
e[cnt].val = 1;
ed = cnt;
continue;
}
}
}
printf("! ");
for(int i = rt;i != -1;i = e[i].nxt)printf("%d",e[i].val);
printf("\n");
fflush(stdout) ;
}
return 0;
}
Codeforces Round 973 (Div. 2) C的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- 【H5】06 网页架构
摘自: https://developer.mozilla.org/zh-CN/docs/Learn/HTML/Introduction_to_HTML/%E6%96%87%E4%BB%B6%E5%9 ...
- AI大模型的技术之母 —— Attention Is All You Need —— Tansformer
论文地址: https://arxiv.org/abs/1706.03762
- 预处理共轭梯度算法(Preconditioned Conjugate Gradients Method)的代码实现
前文: 预处理共轭梯度算法(Preconditioned Conjugate Gradients Method) 给出代码: import numpy as np # from rllab.misc. ...
- 【转载】 Tensorflow如何直接使用预训练模型(vgg16为例)
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/weixin_44633882/artic ...
- 乌克兰学者的学术图谱case1
0. 人物:米哈伊洛·兹古罗夫斯基Mykhailo Zakharovych Zghurovskyi,也拼写为Mykhailo Zgurovsky,(乌克兰语:Михайло Захарович Згу ...
- 7月30日CSP-S模拟赛赛后总结
7月30日模拟赛赛后总结 \[7月30日 \ \ 模拟赛 \ \ 赛后总结 \\ 2024年7月30日 \\ by \ \ \ hcy \] 洛谷同步:点我 一.做题情况 第一题比赛 \(100pts ...
- 用一杯星巴克的钱,训练自己私有化的ChatGPT
文章摘要:用一杯星巴克的钱,自己动手2小时的时间,就可以拥有自己训练的开源大模型,并可以根据不同的训练数据方向加强各种不同的技能,医疗.编程.炒股.恋爱,让你的大模型更"懂"你-. ...
- C#窗体自定义快捷操作键的实现 - 开源研究系列文章
这次想到应用程序的窗体的快捷操作键的使用的问题. 上次发布过一个快捷键的例子(https://www.cnblogs.com/lzhdim/p/18342051),区别在于它是操作系统全局注册的热键, ...
- 12-es6类的方式封装折线图
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="U ...
- Go进程内存占用那些事(一)
为什么要探究这个问题? 作为基础设施供应商,自己的服务占用多少内存,为什么要占用这么多内存,需要能说的清楚.作为一个云计算开发,这点问题都弄不清楚,说不过去. § 0x01 范围 讨论的只限于Linu ...