当前位置:网站首页>2021年ICPC陕西省赛热身赛 B.CODE(位运算)
2021年ICPC陕西省赛热身赛 B.CODE(位运算)
2022-07-25 05:31:00 【Vijurria】
B . CODE
题目描述
给了一个长度为(2^n)-1的01字符串,每一个字节有可能出错的概率是1/10^20。
字符串s,字符s[i],对于每一个i(i=2^k), s[i]满足: s[i]=⨁(s[j]),j&i=i 。【s[i] = the xor sum of all position j which k−th digit is 1 in binary representation.】
eg:s[3]=1,s[5]=1,s[6]=0,s[7]=1
then
s[1]=s[3]⨁s[5]⨁s[7]=1
s[2]=s[3]⨁s[6]⨁s[7]=0
s[4]=s[5]⨁s[6]⨁s[7]=0
The final message to be sent is 1010101。
求原字符串,可以假设所给的字符串最多只有一个错误。输入
3 3 1010101 1010111 1110101输出
1010101 1010101 1010101
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=200200;
const int M=5002;
const int mod=998244353;
LL a[N],f[M][M];
LL mp[N];
int b[N];
bool vis[N];
int dx[]={-1,0,0,1},dy[]={0,1,-1,0};
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int T=1;
cin>>T;
int n;
cin>>n;
while(T--)
{
string s;
cin>>s;
int len=s.size();
s=" "+s;
int flag=0;
for(int i=1;i<=len;i<<=1)
{
int sum=0;
for(int j=1;j<=len;j++)
{
if((j&i)==i&&(i!=j))
{
sum^=(s[j]-'0');
}
}
if(sum!=s[i]-'0') flag|=i;
}
if(flag!=0)
{
if(s[flag]=='0') s[flag]='1';
else s[flag]='0';
}
for(int i=1;i<=len;i++) cout<<s[i];
cout<<endl;
}
return 0;
}边栏推荐
- Leetcode 204. count prime numbers (wonderful)
- LCP plug-in creates peer VLAN interface
- 1310_ Implementation analysis of a printf
- LeetCode第302场周赛
- Redis集群搭建(Windows)
- Deep error
- Uniapp custom application exit execution content
- ThreadLocal
- Leetcode 0121. the best time to buy and sell stocks - simulation from back to front
- STL notes (I): knowledge system
猜你喜欢

单点登录(一处登录,处处可用)

Panda3D keyboard moving scene

Go language function

FinClip实现微信授权登录的三种方案

In depth understanding of pre post + +, -- and negative modulus

VIM search and replacement and the use of regular expressions

Leetcode 202. 快乐数(一点都不快乐)

Easyrecovery free data recovery tool is easy to operate and restore data with one click

Realsense D435i 深度图优化_高精度模式

Game 302 of leetcode
随机推荐
06. Libavdevice Library of ffmpeg
TCL shows a number of folding screen mobile phones: the screen and hinge are independently developed!
Continuous maximum sum and judgement palindrome
Samsung folding screen has sent samples to apple and Google, and the annual production capacity will be expanded from 2.4 million to 10million!
Uniapp custom application exit execution content
Easyrecovery free data recovery tool is easy to operate and restore data with one click
background
聊聊 Redis 是如何进行请求处理
Implement is by yourself_ class
The u-collapse component of uniapp mobile uview is highly init
Summary of common attributes of flex layout
Odoo14 | about the abnormal display of statusbar keyword after use and Its Solutions
单点登录(一处登录,处处可用)
ThreadLocal
STL notes (III): input / output stream
systemverilog中function和task区别
Go language function
Which side of Nacos has the SQL script of this column?
JWT(json web token)
easyrecovery免费数据恢复工具操作简单一键恢复数据