当前位置:网站首页>[sg function] lightoj Partitioning Game
[sg function] lightoj Partitioning Game
2022-07-03 22:03:00 【HeartFireY】
Yes n n n Rubble , You can choose to divide one pile into The quantity is different Two piles of , And it must be divided once . Players who can't score any more lose .
The necessary state in the initial state : s g [ 0 ] = s g [ 1 ] = s g [ 2 ] = 0 sg[0] = sg[1] = sg[2] = 0 sg[0]=sg[1]=sg[2]=0, Then enumerate each stacking method SG Just watch .
Be careful , In seeking MEX Don't use tape when log Data structure of ( such as std::set), Will timeout …
#include <bits/stdc++.h>
//#define int long long
using namespace std;
const int N = 1e4 + 10;
int sg[N], mex[N];
#define win cout << "Alice" << endl
#define lose cout << "Bob" << endl
inline void getsg(){
memset(sg, -1, sizeof(sg));
sg[0] = sg[1] = sg[2] = 0;
for(int i = 3; i <= N; i++){
memset(mex, 0, sizeof mex);
for(int j = 1; j * 2 < i; j++){
mex[sg[j] ^ sg[i - j]]++;
}
int mexv = 0;
while(mex[mexv]) mexv++;
sg[i] = mexv;
}
}
inline void solve(int cas){
cout << "Case " << cas << ": ";
int n = 0; cin >> n;
int ans = 0;
for(int i = 1; i <= n; i++){
int x; cin >> x;
if(i == 1) ans = sg[x];
else ans ^= sg[x];
}
if(ans) win;
else lose;
}
signed main(){
getsg();
int t = 0; cin >> t;
for(int i = 1; i <= t; i++) solve(i);
return 0;
}
边栏推荐
- On my first day at work, this API timeout optimization put me down!
- Persistence of Nacos
- IPhone development swift foundation 09 assets
- Introduction to kubernetes
- 4. Data splitting of Flink real-time project
- Development mode and Prospect of China's IT training industry strategic planning trend report Ⓣ 2022 ~ 2028
- 十大券商开户注册安全靠谱吗?有没有风险的?
- Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
- 国泰君安证券开户是安全可靠的么?怎么开国泰君安证券账户
- Awk getting started to proficient series - awk quick start
猜你喜欢

A little understanding of GSLB (global server load balance) technology

2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)

(5) User login - services and processes - History Du touch date stat CP

How PHP drives mongodb

MySQL——JDBC

IPhone development swift foundation 09 assets

Tidb's initial experience of ticdc6.0

QFileDialog

Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
随机推荐
Memory analyzer (MAT)
JS closure knowledge points essence
6.0 kernel driver character driver
Awk getting started to proficient series - awk quick start
Investment analysis and prospect trend prediction report of China's boron nitride industry Ⓨ 2022 ~ 2028
WiFi 2.4g/5g/6g channel distribution
Implementation principle of inheritance, encapsulation and polymorphism
Capturing and sorting out external articles -- autoresponder, composer, statistics [III]
On my first day at work, this API timeout optimization put me down!
China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
js demo 計算本年度還剩下多少天
Sed、Awk
Leetcode problem solving - 230 The k-th smallest element in the binary search tree
Introduction to kubernetes
gslb(global server load balance)技术的一点理解
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
Luogu deep foundation part 1 Introduction to language Chapter 6 string and file operation
MySQL——JDBC
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)