当前位置:网站首页>[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;
}
边栏推荐
- Global and Chinese market of recycled yarn 2022-2028: Research Report on technology, participants, trends, market size and share
- A little understanding of GSLB (global server load balance) technology
- Nacos common configuration
- 使用dnSpy对无源码EXE或DLL进行反编译并且修改
- Rest reference
- Development mode and Prospect of China's IT training industry strategic planning trend report Ⓣ 2022 ~ 2028
- JS Demo calcule combien de jours il reste de l'année
- How PHP adds two numbers
- Awk getting started to proficient series - awk quick start
- What indicators should be paid attention to in current limit monitoring?
猜你喜欢
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
常用sql集合
gslb(global server load balance)技術的一點理解
Data consistency between redis and database
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
How PHP drives mongodb
Imitation Netease cloud music applet
No matter how hot the metauniverse is, it cannot be separated from data
Teach you how to install aidlux (1 installation)
How PHP gets all method names of objects
随机推荐
Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
js demo 計算本年度還剩下多少天
Redis concludes that the second pipeline publishes / subscribes to bloom filter redis as a database and caches RDB AOF redis configuration files
Report on the development status and investment planning trends of China's data center industry Ⓡ 2022 ~ 2028
仿网易云音乐小程序
Après 90 ans, j'ai démissionné pour démarrer une entreprise et j'ai dit que j'allais détruire la base de données Cloud.
Is it safe and reliable to open an account and register for stock speculation? Is there any risk?
Leetcode problem solving - 230 The k-th smallest element in the binary search tree
Introduction to kubernetes
Preliminary understanding of C program design
Implementation principle of inheritance, encapsulation and polymorphism
Collection | pytoch common loss function disassembly
Let me ask you a question. Have you ever used the asynchronous io of Flink SQL to associate dimension tables in MySQL? I set various settings according to the official website
常用sql集合
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
使用dnSpy对无源码EXE或DLL进行反编译并且修改
What should the future of the Internet be like when Silicon Valley employees flee the big factory and rush to Web3| Footprint Analytics
Day 9 HomeWrok-ClassHierarchyAnalysis
Imitation Netease cloud music applet
On my first day at work, this API timeout optimization put me down!