当前位置:网站首页>[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;
}
边栏推荐
- JS closure knowledge points essence
- 90 後,辭職創業,說要卷死雲數據庫
- The White House held an open source security summit, attended by many technology giants
- 使用dnSpy對無源碼EXE或DLL進行反編譯並且修改
- 常用sql集合
- China's Call Center Industry 14th five year plan direction and operation analysis report Ⓔ 2022 ~ 2028
- [dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
- Global and Chinese market of gallic acid 2022-2028: Research Report on technology, participants, trends, market size and share
- Compréhension de la technologie gslb (Global Server load balance)
- Netfilter ARP log
猜你喜欢
Functions and differences between static and Const
What should the future of the Internet be like when Silicon Valley employees flee the big factory and rush to Web3| Footprint Analytics
MySQL - database backup
Station B, dark horse programmer, employee management system, access conflict related (there is an unhandled exception at 0x00007ff633a4c54d (in employee management system.Exe): 0xc0000005: read locat
[SRS] build a specified version of SRS
On my first day at work, this API timeout optimization put me down!
Covariance
A little understanding of GSLB (global server load balance) technology
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Common SQL sets
随机推荐
使用dnSpy對無源碼EXE或DLL進行反編譯並且修改
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
Imitation Netease cloud music applet
Are the top ten securities companies safe to open accounts and register? Is there any risk?
JS notes (III)
Luogu deep foundation part 1 Introduction to language Chapter 7 functions and structures
油猴插件
Kali2021.4a build PWN environment
抓包整理外篇——————autoResponder、composer 、statistics [ 三]
油猴插件
Covariance
Global and Chinese market of gallic acid 2022-2028: Research Report on technology, participants, trends, market size and share
Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
Yyds dry inventory Chapter 4 of getting started with MySQL: data types that can be stored in the data table
2022-02-15 Daily: 2022 AAAI fellow release
Analysis report on the development prospect and investment strategy of global and Chinese modular automation systems Ⓟ 2022 ~ 2027
What indicators should be paid attention to in current limit monitoring?
Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?