当前位置:网站首页>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";
}
边栏推荐
- One question per day 1020 Number of enclaves
- 1040 Longest Symmetric String
- In depth analysis of for (VaR I = 0; I < 5; i++) {settimeout (() => console.log (I), 1000)}
- Nested method, calculation attribute is not applicable, use methods
- NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar
- 【Rust 笔记】15-字符串与文本(下)
- Applicable to Net free barcode API [off] - free barcode API for NET [closed]
- 快速使用Amazon MemoryDB并构建你专属的Redis内存数据库
- SQLMAP使用教程(一)
- [leetcode] day95 effective Sudoku & matrix zeroing
猜你喜欢
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
SPI 详解
Doing SQL performance optimization is really eye-catching
LeetCode-61
LeetCode 0108. Convert an ordered array into a binary search tree - the median of the array is the root, and the left and right of the median are the left and right subtrees respectively
MySQL advanced part 1: stored procedures and functions
Leetcode array operation
MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
QQ电脑版取消转义符输入表情
博弈论 AcWing 894. 拆分-Nim游戏
随机推荐
Open source storage is so popular, why do we insist on self-development?
[rust notes] 17 concurrent (Part 2)
Redis publish subscribe command line implementation
LeetCode 0107. Sequence traversal of binary tree II - another method
博弈论 AcWing 893. 集合-Nim游戏
A reason that is easy to be ignored when the printer is offline
Single chip computer engineering experience - layered idea
Doing SQL performance optimization is really eye-catching
【Rust 笔记】14-集合(上)
Traversal of leetcode tree
快速使用Amazon MemoryDB并构建你专属的Redis内存数据库
Leetcode-1200: minimum absolute difference
[leetcode] day94 reshape matrix
redis发布订阅命令行实现
多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
数据可视化图表总结(一)
Leetcode-6108: decrypt messages
中国剩余定理 AcWing 204. 表达整数的奇怪方式
Multi screen computer screenshots will cut off multiple screens, not only the current screen
Arduino 控制的 RGB LED 无限镜