当前位置:网站首页>P2575 master fight
P2575 master fight
2022-07-05 06:19:00 【Strezia】
Link
sg function
A very clever question , Originally intended to violence pretreatment 2 20 ∗ 20 2^{20}*20 220∗20 It's a state, but it doesn't write violence , See the problem solution can be transformed into a ladder Nim, great .
Code
int n;
int a[25];
int sg[25];
void solve() {
cin >> n;
int ans = 0;
for(int i = 1; i <= n; i++) {
int m;
cin >> m;
memset(a, 0, sizeof(a));
memset(sg, 0, sizeof(sg));
int ans1 = 0;
while(m--) {
int x;
cin >> x;
a[x]++;
}
int tmp = 0;
int now = 0;
for(int i = 20; i; i--) {
if(a[i]) {
tmp++; continue;}
sg[++now] = tmp;
tmp = 0;
}
sg[++now] = tmp;
tmp = 0;
for(int i = 0; i <= now; i += 2)
ans1 ^= sg[i];
ans ^= ans1;
}
if(ans) cout << "YES\n";
else cout << "NO\n";
}
边栏推荐
- 高斯消元 AcWing 884. 高斯消元解异或线性方程组
- Liunx starts redis
- Usage scenarios of golang context
- Error ora-28547 or ora-03135 when Navicat connects to Oracle Database
- What's wrong with this paragraph that doesn't work? (unresolved)
- MySQL advanced part 2: MySQL architecture
- Records of some tools 2022
- 【Rust 笔记】17-并发(上)
- Overview of variable resistors - structure, operation and different applications
- LaMDA 不可能觉醒吗?
猜你喜欢

快速使用Amazon MemoryDB并构建你专属的Redis内存数据库

可变电阻器概述——结构、工作和不同应用

博弈论 AcWing 893. 集合-Nim游戏

Spark中groupByKey() 和 reduceByKey() 和combineByKey()

MySQL advanced part 1: stored procedures and functions

阿里新成员「瓴羊」正式亮相,由阿里副总裁朋新宇带队,集结多个核心部门技术团队

MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理

Leetcode-6111: spiral matrix IV

NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar

博弈论 AcWing 894. 拆分-Nim游戏
随机推荐
11-gorm-v2-03-basic query
Single chip computer engineering experience - layered idea
What is socket? Basic introduction to socket
1.13 - RISC/CISC
4. Object mapping Mapster
开源存储这么香,为何我们还要坚持自研?
Leetcode-6108: decrypt messages
Liunx starts redis
In depth analysis of for (VaR I = 0; I < 5; i++) {settimeout (() => console.log (I), 1000)}
Leetcode-6109: number of people who know secrets
[rust notes] 16 input and output (Part 2)
Operator priority, one catch, no doubt
LeetCode-61
1039 Course List for Student
【Rust 笔记】14-集合(下)
MIT-6874-Deep Learning in the Life Sciences Week 7
How to understand the definition of sequence limit?
传统数据库逐渐“难适应”,云原生数据库脱颖而出
【Rust 笔记】17-并发(上)
liunx启动redis