当前位置:网站首页>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";
}
边栏推荐
猜你喜欢

WordPress switches the page, and the domain name changes back to the IP address

MySQL advanced part 2: the use of indexes

Leetcode stack related

Leetcode-6110: number of incremental paths in the grid graph

Open source storage is so popular, why do we insist on self-development?

Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
![Introduction to LVS [unfinished (semi-finished products)]](/img/72/d5a943a8d6d71823dcbd7f23dda35b.png)
Introduction to LVS [unfinished (semi-finished products)]
![[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis](/img/20/826cc9d514496955a557439881234d.jpg)
[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis

Leetcode array operation

可变电阻器概述——结构、工作和不同应用
随机推荐
Leetcode-6109: number of people who know secrets
redis发布订阅命令行实现
MySQL advanced part 2: MySQL architecture
1040 Longest Symmetric String
Appium foundation - use the first demo of appium
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
1.13 - RISC/CISC
Record the process of configuring nccl and horovod in these two days (original)
[rust notes] 14 set (Part 2)
SQL三种连接:内连接、外连接、交叉连接
__ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
【Rust 笔记】15-字符串与文本(下)
Leetcode-9: palindromes
Sqlmap tutorial (1)
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
Filter the numbers and pick out even numbers from several numbers
1.14 - assembly line
Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
MySQL advanced part 1: index
Liunx starts redis