当前位置:网站首页>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;
}边栏推荐
- Browser cache HTTP cache CDN cache localstorage / sessionstorage / cookies
- JWT(json web token)
- Which side of Nacos has the SQL script of this column?
- STL notes (II): template and operator overloading
- JS common code questions array de duplication - Custom New throttling and anti shake - deep copy - instanceof URL parameter extraction - thousand separator - array to tree structure - array flattening
- Leetcode 15: sum of three numbers
- STL notes (VIII): container - List
- 聊聊 Redis 是如何进行请求处理
- Wechat applet related operation examples
- The selection reference of Junzheng T41, T40 and T31 versions are all here
猜你喜欢

微信小程序相关操作示例

How to carry out the function test with simple appearance and complex interior?
![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](/img/1b/b8529b6f1d163a9e5d5dad2b78ce93.png)
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

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

Execution process of NPM run XX

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

Microservice gateway component

项目管理工具——项目开发者工具

C Programming -- the solution of dynamic programming of "the sum of the largest subarray"

Introduction to base ring tree
随机推荐
In depth understanding of pre post + +, -- and negative modulus
Airserver 7.3.0 Chinese version mobile device wireless transmission computer screen tool
Concepts of phase velocity and phase in transmission line theory
STL notes (VIII): container - List
LCP插件创建对等802.1ad接口
传输线理论之相速、相位等的概念
uniapp手机端uView的u-collapse组件高度init
AirServer 7.3.0中文版手机设备无线传送电脑屏幕工具
Preliminary understanding of Panda3D particle system
School day (summer vacation daily question 2)
Nexttick principle analysis
Tips for downloading videos in batches
微服务及相关组件概念
LCP plug-in creates peer VLAN interface
Project management tools - project developer tools
Leetcode 202. happy number (not happy at all)
Uniapp custom application exit execution content
Automatic usage in SystemVerilog
ping命令
What is virtual DOM? How to implement a virtual DOM