当前位置:网站首页>Codeforces 1629 E. grid XOR - simple thinking
Codeforces 1629 E. grid XOR - simple thinking
2022-06-12 13:32:00 【Tianyi City*】
The question :
Give you a two-dimensional array b,b[i][j]=a[i][j+1]^a[i][j-1]^a[i+1][j]^a[i-1][j]. Let you output a The exclusive or sum of all values of .
Answer key :
I didn't see the XOR and , So it's early enough , Maybe it wants to find rules from this ? I'll find out later
First, let me assume that the first line is all 0, How to think of all for 0 Well , Because we need a starting point … I'll just give you more details .
The first line is all 0 after , Is the second line all known , Then the third line , In the fourth row … All can be pushed out . At first I thought I would make mistakes in the last line , So it's just a bit of a painting , But it doesn't seem to go wrong ? Probably originally a[1][1] Should be x Of , I become 0 after x I was a[1][2] and a[2][1] Let's go .
That's too much water , Just calculate directly .
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int a[N][N],b[N][N],n;
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
scanf("%d",&b[i][j]);
for(int i=1;i<n;i++)
for(int j=1;j<=n;j++)
a[i+1][j]=b[i][j]^a[i][j-1]^a[i][j+1]^a[i-1][j];
int ans=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
ans^=a[i][j],a[i][j]=0;
printf("%d\n",ans);
}
return 0;
}
边栏推荐
猜你喜欢

Successfully rated Tencent t3-2, 10000 word parsing

C#DBHelper_FactoryDB_GetConn
![[EDA] chip layout design: VLSI layout design using electric](/img/a1/da0739070c940b36bc7a55d8eb2fe5.jpg)
[EDA] chip layout design: VLSI layout design using electric

It is enough to read this article. Web Chinese development

单向环形链表实现约瑟夫环

LeetCode滑动窗口刷题总结

多源BFS问题 模板(附题)

Innovation training (x) advanced interface beautification

There was an error installing mysql. Follow the link below to CMD

D1 Nezha Development Board understands the basic startup and loading process
随机推荐
Actual combat | realizing monocular camera ranging by skillfully using pose solution
Introduction to application design scheme of intelligent garbage can voice chip, wt588f02b-8s
Seekg, tellg related file operations
2068: [example 2.6] chicken and rabbit in the same cage
import torch_geometric 的Data 查看
苹果电脑上MySQL安装完成找不到怎么办
5V升压到12.6V的锂电池充电IC芯片方案FS4062B
C language [23] classic interview questions [2]
C language structure
【云原生 | Kubernetes篇】深入了解Ingress
There was an error installing mysql. Follow the link below to CMD
view的子视图的递归
Installation of pagoda
How to solve the problem of data table query error when SQLite writes the registration function?
Getting started with NVIDIA Jetson nano Developer Kit
数据类型转换和条件控制语句
Application of binary search -- finding the square root sqrt of a number
D1 Nezha Development Board understands the basic startup and loading process
镜像扫描工具预研
Automatic Generation of Visual-Textual Presentation Layout