当前位置:网站首页>2021 ICPC Shaanxi warm up match b.code (bit operation)
2021 ICPC Shaanxi warm up match b.code (bit operation)
2022-07-25 05:33:00 【Vijurria】
B . CODE
Title Description
A length of (2^n)-1 Of 01 character string , The probability that every byte may be wrong is 1/10^20.
character string s, character s[i], For each of these i(i=2^k), s[i] Satisfy : 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.
Find the original string , You can assume that the given string has at most one error .Input
3 3 1010101 1010111 1110101Output
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;
}边栏推荐
- STL notes (II): template and operator overloading
- 05. Libavformat Library of ffmpeg
- STL notes (VIII): container - List
- Which side of Nacos has the SQL script of this column?
- 50: Chapter 5: develop admin management service: 3: develop [query whether the admin user name already exists, interface]; (this interface can only be called when logging in; so we have written an int
- SystemVerilog中$write与$display区别
- FinClip实现微信授权登录的三种方案
- Typera+picgo+ Alibaba cloud OSS setup and error reporting solution [reprint]
- JWT(json web token)
- obj文件格式与.mtl文件格式
猜你喜欢

Browser cache HTTP cache CDN cache localstorage / sessionstorage / cookies

Preliminary understanding of Panda3D particle system

Game 302 of leetcode

VIM search and replacement and the use of regular expressions

STL notes (IV): String

Implement is by yourself_ class

Execution process of NPM run XX

聊聊 Redis 是如何进行请求处理

微信小程序相关操作示例

Leetcode 204. 计数质数(太妙了)
随机推荐
LeetCode 15:三数之和
Programming hodgepodge (II)
Shenzhen on call test, subject 4 on call test, subject 3 theory, second theory on call test instructions
深圳随到随考,科目四随到随考,科三理论第二理论随到随考说明
剑指offer专项突击版第9天
Three schemes for finclip to realize wechat authorized login
Microservice gateway component
Leetcode 202. 快乐数(一点都不快乐)
flex布局常用属性总结
Three billion dollars! Horizon becomes the world's highest valued AI chip Unicorn
How to carry out the function test with simple appearance and complex interior?
Tips for downloading videos in batches
05. Libavformat Library of ffmpeg
Bug --- redis deserialization failed
Redis cluster setup (Windows)
Realsense D435i 深度图优化_高精度模式
Array programming problem of CSDN programming challenge
background
Win11 how to view the file explorer tab
自己实现is_base_of