Educational Codeforces Round 71 (Rated for Div. 2) E XOR Guessing (二进制分组,交互)
E. XOR Guessing
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307.
The jury picked an integer x not less than 0 and not greater than 214−1. You have to guess this integer.
To do so, you may ask no more than 2 queries. Each query should consist of 100 integer numbers a1, a2, ..., a100 (each integer should be not less than 0 and not greater than 214−1). In response to your query, the jury will pick one integer i (1≤i≤100) and tell you the value of ai⊕x (the bitwise XOR of ai and x). There is an additional constraint on the queries: all 200 integers you use in the queries should be distinct.
It is guaranteed that the value of x is fixed beforehand in each test, but the choice of i in every query may depend on the integers you send.
Output
To give the answer, your program should print one line ! x with a line break in the end. After that, it should flush the output and terminate gracefully.
Interaction
Before giving the answer, you may submit no more than 2 queries. To ask a query, print one line in the following format: ? a1 a2 ... a100, where every aj should be an integer from the range [0,214−1]. The line should be ended with a line break character. After submitting a query, flush the output and read the answer to your query — the value of ai⊕x for some i∈[1,100]. No integer can be used in queries more than once.
If you submit an incorrect query (or ask more than 2 queries), the answer to it will be one integer −1. After receiving such an answer, your program should terminate immediately — otherwise you may receive verdict "Runtime error", "Time limit exceeded" or some other verdict instead of "Wrong answer".
Example
inputCopy
0
32
outputCopy
? 3 5 6
? 32 24 37
! 5
Note
The example of interaction is not correct — you should sumbit exactly 100 integers in each query. Everything else is correct.
Hacks are forbidden in this problem.
思路:
只看14位,第一个集合,后7为全放0,第二个集合,前7位放0,然后询问得到的答案,取第一个回复的后7位,第二个回复的前7位。。
什么200个数相互不同,例如第一个集合,后7位放0后,前7位随便取点不同的就好了。
细节见代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
inline void getInt(int* p);
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
std::vector<int> v;
void PRINF2(ll num, int k)
{
for (int i = k; i >= 0; i--)
{
cout << (bool)(num & (1ll << i));
}
cout << endl;
}
int main()
{
//freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
int maxst = (1 << 8);
int n = 100;
v.clear();
repd(i, 1, n)
{
int x = 0;
x <<= 7;
x += i;
v.push_back(x);
}
cout << "?";
for (auto x : v)
{
cout << " " << x;
}
cout << endl;
int ans;
cin >> ans;
ans >>= 7;
ans <<= 7;
v.clear();
repd(i, 1, n)
{
int x = 0;
x += (i << 7);
v.push_back(x);
// PRINF2(x,25);
}
cout << "?";
for (auto x : v)
{
cout << " " << x;
}
cout << endl;
int y;
cin >> y;
for (int i = 6; i >= 0; --i)
{
if (y & (1 << i))
{
ans += (1 << i);
}
}
cout << "! " << ans << endl;
return 0;
}
inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {
*p = *p * 10 - ch + '0';
}
}
else {
*p = ch - '0';
while ((ch = getchar()) >= '0' && ch <= '9') {
*p = *p * 10 + ch - '0';
}
}
}
Educational Codeforces Round 71 (Rated for Div. 2) E XOR Guessing (二进制分组,交互)的更多相关文章
- Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing
一道容斥题 如果直接做就是找到所有出现过递减的不同排列,当时硬钢到自闭,然后在凯妹毁人不倦的教导下想到可以容斥做,就是:所有的排列设为a,只考虑第一个非递减设为b,第二个非递减设为c+两个都非递减的情 ...
- Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] 总共两次询 ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- [暴力] Educational Codeforces Round 71 (Rated for Div. 2) B. Square Filling (1207B)
题目:http://codeforces.com/contest/1207/problem/B B. Square Filling time limit per test 1 second mem ...
- [贪心,dp] Educational Codeforces Round 71 (Rated for Div. 2) C. Gas Pipeline (1207C)
题目:http://codeforces.com/contest/1207/problem/C C. Gas Pipeline time limit per test 2 seconds memo ...
- Educational Codeforces Round 71 (Rated for Div. 2)
传送门 A.There Are Two Types Of Burgers 签到. B.Square Filling 签到 C.Gas Pipeline 每个位置只有"高.低"两种状 ...
- Educational Codeforces Round 71 (Rated for Div. 2) Solution
A. There Are Two Types Of Burgers 题意: 给一些面包,鸡肉,牛肉,你可以做成鸡肉汉堡或者牛肉汉堡并卖掉 一个鸡肉汉堡需要两个面包和一个鸡肉,牛肉汉堡需要两个面包和一个 ...
- Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)
引用:https://blog.csdn.net/qq_41879343/article/details/100565031 下面代码写错了,注意要上面这种.查:2 800 0,下面代码就错了. ...
- XOR Guessing(交互题+思维)Educational Codeforces Round 71 (Rated for Div. 2)
题意:https://codeforc.es/contest/1207/problem/E 答案guessing(0~2^14-1) 有两次机会,内次必须输出不同的100个数,每次系统会随机挑一个你给 ...
随机推荐
- PHP SQL注入
开发者容易遗漏的输入点: HTTP头 X-Forwarded-For 获取用户ip User-Agent 获取浏览器 Referer 获取之 ...
- 【科普杂谈】IP地址子网划分
1.学习子网前的准备知识-什么是数制 现场讲解版 二进制和十进制的关系 二进制和十六进制的关系 16进制的每个位是2进制的4位 F=1111 二进制转16进制,按上面4位一组分开转 2.IP地 ...
- 关于bootstrap的响应式插件respond.min.js在IE8下出现:拒绝访问。respond.min.js,行: 5,列: 746报错问题
本地在IE8浏览器下测试兼容性的时候,出现了以下的报错: 该问题在bootstrap的官网有介绍:https://v3.bootcss.com/getting-started
- (企业面试)描述Linux系统的启动过程?
1简单描述(口头): 1.开机BIOS自检(检查硬件,cpu,主板,内存……) 2. MBR引导 硬盘 0 柱面 0 磁道 1 扇区的前446byte 3. grub 引导菜单 cat/etc/gr ...
- gdb移植(交叉版本)
Gdb下载地址: http://ftp.gnu.org/gnu/gdb/ termcap下载地址:http://ftp.gnu.org/gnu/termcap/tar -zxvf termcap-1. ...
- redis 慢查询、Pipeline
1.慢查询 简介 慢查询顾名思义是将redis执行命令较慢的命令记录下来,redis处理慢查询时是将慢查询记录到慢查询队列中 慢查询配置 slowlog-max-len 慢查询队列长度(记录多少条慢查 ...
- 这可能是最简单易懂的 ZooKeeper 笔记
分布式架构 CAP 与 BASE 理论 一致性协议 初识 Zookeeper Zookeeper 介绍 Zookeeper 工作机制 Zookeeper 特点 Zookeeper 数据结构 Zooke ...
- 学习 Laravel - Web 开发实战入门笔记(1)
本笔记根据 LearnKu 教程边学边记而成.该教程以搭建出一个类似微博的Web 应用为最终成果,在过程中学习 Laravel 的相关知识. 准备开发环境 原教程使用官方推荐的 Homestead 开 ...
- MySQL-复杂查询及条件-起别名-多表查询-04
目录 基本查询语句及方法 测试数据创建 创建数据库与表 插入表记录数据 数据展示 常见结果排版 另一种结果排版 \G 简单查询语句的书写与执行顺序 查询语句书写 执行顺序 科普-- 起别名 写法 可以 ...
- Web项目测试流程总结
个人知识脑图总结 - 未完全(工作项目脑图总结存于网盘中)