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 (二进制分组,交互)的更多相关文章

  1. Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing

    一道容斥题 如果直接做就是找到所有出现过递减的不同排列,当时硬钢到自闭,然后在凯妹毁人不倦的教导下想到可以容斥做,就是:所有的排列设为a,只考虑第一个非递减设为b,第二个非递减设为c+两个都非递减的情 ...

  2. Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题

    Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] ​ 总共两次询 ...

  3. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  4. [暴力] 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 ...

  5. [贪心,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 ...

  6. Educational Codeforces Round 71 (Rated for Div. 2)

    传送门 A.There Are Two Types Of Burgers 签到. B.Square Filling 签到 C.Gas Pipeline 每个位置只有"高.低"两种状 ...

  7. Educational Codeforces Round 71 (Rated for Div. 2) Solution

    A. There Are Two Types Of Burgers 题意: 给一些面包,鸡肉,牛肉,你可以做成鸡肉汉堡或者牛肉汉堡并卖掉 一个鸡肉汉堡需要两个面包和一个鸡肉,牛肉汉堡需要两个面包和一个 ...

  8. Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)

    引用:https://blog.csdn.net/qq_41879343/article/details/100565031 下面代码写错了,注意要上面这种.查:2  800  0,下面代码就错了. ...

  9. XOR Guessing(交互题+思维)Educational Codeforces Round 71 (Rated for Div. 2)

    题意:https://codeforc.es/contest/1207/problem/E 答案guessing(0~2^14-1) 有两次机会,内次必须输出不同的100个数,每次系统会随机挑一个你给 ...

随机推荐

  1. uni-app相关

    uni-app 中以下组件的高度是固定的,不可修改: 导航栏高度固定为 44pxtabBar 高度固定为 56px 状态栏比较特殊,是一个变量 .status_bar{ height: var(--s ...

  2. MariaDB基本知识点总结01--介绍+语句

    一.概念 1.数据库介绍: 简单的说,数据库就是一个存放数据的仓库,这个仓库是按照一定的数据结构(数据结构是指数据的组织形式或数据之间的联系)来组织,存储的,我们可以通过数据库提供的多种方法来管理数据 ...

  3. svn服务器端的更新操作

    svn up需要在 非svn库中进行操作 ,一般在网站www目录下操作

  4. [转帖]方正数码发布基于龙芯3A3000系列整机

    方正数码发布基于龙芯3A3000系列整机 http://www.loongson.cn/news/company/730.html 方正数码也出过龙芯相关的服务器和PC笔记本等 发布时间:2019-0 ...

  5. css动画(transition/transform/animation)

    在开发中,一个好的用户操作界面,总会夹杂着一些动画.css用对少的代码,来给用户最佳的体验感,下面我总结了一些css动画属性的使用方法及用例代码供大家参考,在不对的地方,希望大佬直接拍砖评论. 1 t ...

  6. GitHub 将源代码保存在北极洞穴,至少使用 1000 年!

    最近,GitHub分享了开放Arctic Code Vault的计划,该计划旨在存储和保存Flutter和TensorFlow等开源软件. 所有开放源代码项目的代码都将存储在胶片上,该胶片每帧包含88 ...

  7. Spring系列三:IoC 与 DI

    水晶帘动微风起,满架蔷薇一院香. 概述 在软件工程中,控制反转(IoC)是一种设计思想,对象之间耦合在一起,在运行时自动绑定,并且它们编译时对所需要引用的对象是不确定的.在这个spring教程中,通过 ...

  8. Arthas查看Spring配置

    在开发过程经常有同学问:"我这个配置更新提交了,怎么样知道项目中是否已经更新使用新值?" 常用的方法是添加日志打印该值判断是否更新.今天我们用Arthas来实现项目中配置值实时读取 ...

  9. logid让你的请求完整可追溯

    今天是在博客园开园的第一天 一时间其实并不能想起来到底该写什么文章,其实想写的东西挺多 今天就以logid这个主题开始吧,网上写这个的文章似乎不多,但是的确是在实际生产中相当重要的一个能力,也是容易被 ...

  10. PHP 协程:Go + Chan + Defer

    Swoole4为PHP语言提供了强大的CSP协程编程模式.底层提供了3个关键词,可以方便地实现各类功能. Swoole4提供的PHP协程语法借鉴自Golang,在此向GO开发组致敬 PHP+Swool ...