当前位置:网站首页>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";
}
边栏推荐
- How to generate an image from text on fly at runtime
- 1039 Course List for Student
- Sqlmap tutorial (II) practical skills I
- Regulations for network security events of vocational group in 2022 Guizhou Vocational College skill competition
- 快速使用Amazon MemoryDB并构建你专属的Redis内存数据库
- Shutter web hardware keyboard monitoring
- 【Rust 笔记】16-输入与输出(上)
- Leetcode array operation
- 背包问题 AcWing 9. 分组背包问题
- Leetcode-22: bracket generation
猜你喜欢
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
Arduino 控制的 RGB LED 无限镜
There are three kinds of SQL connections: internal connection, external connection and cross connection
MySQL advanced part 1: index
MySQL advanced part 2: MySQL architecture
博弈论 AcWing 894. 拆分-Nim游戏
LeetCode 0107. Sequence traversal of binary tree II - another method
SQL三种连接:内连接、外连接、交叉连接
Leetcode-6108: decrypt messages
随机推荐
[rust notes] 15 string and text (Part 1)
MySQL advanced part 1: stored procedures and functions
[rust notes] 16 input and output (Part 2)
可变电阻器概述——结构、工作和不同应用
LeetCode 1200. Minimum absolute difference
Leetcode-31: next spread
Record the process of configuring nccl and horovod in these two days (original)
[leetcode] day95 effective Sudoku & matrix zeroing
Spark中groupByKey() 和 reduceByKey() 和combineByKey()
Sum of three terms (construction)
【Rust 笔记】13-迭代器(中)
阿里新成员「瓴羊」正式亮相,由阿里副总裁朋新宇带队,集结多个核心部门技术团队
Sword finger offer II 058: schedule
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
博弈论 AcWing 891. Nim游戏
Doing SQL performance optimization is really eye-catching
Niu Mei's math problems
Sqlmap tutorial (II) practical skills I
高斯消元 AcWing 884. 高斯消元解异或线性方程组