当前位置:网站首页>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;
}
边栏推荐
- 【云原生 | Kubernetes篇】深入了解Deployment(八)
- Openstack network
- static 和 extern 关键字详解
- Pytorch framework
- go-zero 微服务实战系列(二、服务拆分)
- 2061: [example 1.2] trapezoidal area
- 颜色编码格式介绍
- import torch_ Geometric loads some common datasets
- 2063: [example 1.4] cattle eat grass
- Script import CDN link prompt net:: err_ FILE_ NOT_ Found problem
猜你喜欢

list和dict的应用

403 you don't have permission to access this resource

Actual combat | realizing monocular camera ranging by skillfully using pose solution

5V升压到12.6V的锂电池充电IC芯片方案FS4062B

import torch_ Data view of geometric

How to balance multiple losses in deep learning?

创新实训(十)高级界面美化

Scyther工具形式化分析Woo-Lam协议

Qualcomm platform development series (Protocol) QMI brief introduction and usage

高通平台开发系列讲解(协议篇)QMI简单介绍及使用方法
随机推荐
2061: [example 1.2] trapezoidal area
Install RPM package offline using yum
Record some settings for visual studio 2019
创新实训(十二)项目总结
2067: [example 2.5] circle
Paw 高级使用指南
章鱼网络进展月报 | 2022.5.1-5.31
【云原生 | Kubernetes篇】深入了解Ingress
【云原生 | Kubernetes篇】Ingress案例实战
【云原生 | Kubernetes篇】深入了解Deployment(八)
智能垃圾桶语音芯片应用设计方案介绍,WT588F02B-8S
Getting started with NVIDIA Jetson nano Developer Kit
A brief introduction to Verilog mode
Does jupyternotebook have a Chinese character database. Can you recognize handwritten Chinese in deep learning
m1 pod install pod lint 失败解决方案
2066: [example 2.3] buying books
Time processing in C language (conversion between string and timestamp)
Stm32f1 and stm32cubeide programming examples - device driver -eeprom-at24c256 driver
开发中使用的语言技巧
5V升压到12.6V的锂电池充电IC芯片方案FS4062B