当前位置:网站首页>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";
}
边栏推荐
- JS quickly converts JSON data into URL parameters
- Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
- Nested method, calculation attribute is not applicable, use methods
- 多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
- Appium foundation - use the first demo of appium
- What's wrong with this paragraph that doesn't work? (unresolved)
- 数据可视化图表总结(二)
- Usage scenarios of golang context
- 【Rust 笔记】16-输入与输出(上)
- Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
猜你喜欢
![[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian](/img/f1/e7a8a1a31bc5712d9f32d91305a2b0.jpg)
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian

Navicat連接Oracle數據庫報錯ORA-28547或ORA-03135

4. 对象映射 - Mapping.Mapster

Leetcode-6108: decrypt messages

Sqlmap tutorial (1)
![[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields](/img/65/7fa32cd0005ddaaebacd85c25e0c7e.jpg)
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields

Real time clock (RTC)

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 2: MySQL architecture

MySQL advanced part 2: the use of indexes
随机推荐
4. 对象映射 - Mapping.Mapster
Records of some tools 2022
[rust notes] 17 concurrent (Part 2)
Regulations for network security events of vocational group in 2022 Guizhou Vocational College skill competition
[leetcode] day95 effective Sudoku & matrix zeroing
MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
LeetCode 0107. Sequence traversal of binary tree II - another method
Nested method, calculation attribute is not applicable, use methods
Open source storage is so popular, why do we insist on self-development?
MySQL advanced part 2: optimizing SQL steps
Appium自动化测试基础 — Appium测试环境搭建总结
【Rust 笔记】16-输入与输出(下)
2021apmcm post game Summary - edge detection
1039 Course List for Student
MySQL advanced part 2: MySQL architecture
[rust notes] 15 string and text (Part 1)
Leetcode-22: bracket generation
博弈论 AcWing 894. 拆分-Nim游戏
[rust notes] 16 input and output (Part 2)
Leetcode heap correlation