当前位置:网站首页>[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;
}
边栏推荐
- Common SQL sets
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- [vulnhub shooting range] impulse: lupinone
- js demo 計算本年度還剩下多少天
- MySQL——JDBC
- Compréhension de la technologie gslb (Global Server load balance)
- How to install sentinel console
- A little understanding of GSLB (global server load balance) technology
- Is the account opening of Guotai Junan Securities safe and reliable? How to open Guotai Junan Securities Account
- Are the top ten securities companies safe to open accounts and register? Is there any risk?
猜你喜欢

How PHP gets all method names of objects

MySQL——JDBC

gslb(global server load balance)技术的一点理解

Decompile and modify the non source exe or DLL with dnspy

使用dnSpy對無源碼EXE或DLL進行反編譯並且修改

treevalue——Master Nested Data Like Tensor

Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?

Compréhension de la technologie gslb (Global Server load balance)
Implementation principle of inheritance, encapsulation and polymorphism

The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
随机推荐
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
股票炒股开户注册安全靠谱吗?有没有风险的?
Why use pycharm to run the use case successfully but cannot exit?
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
What if the Flink SQL client exits and the table is emptied?
How PHP gets all method names of objects
Analysis report on the development prospect and investment strategy of global and Chinese modular automation systems Ⓟ 2022 ~ 2027
仿网易云音乐小程序
gslb(global server load balance)技术的一点理解
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
Development trend and market demand analysis report of China's energy storage battery industry Ⓩ 2022 ~ 2028
No more! Technical team members resign collectively
DR-NAS26-Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-5GHz-high-power-Mini-PCIe-Wi-Fi-Module
What indicators should be paid attention to in current limit monitoring?
QFileDialog
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Global and Chinese market of recycled yarn 2022-2028: Research Report on technology, participants, trends, market size and share
Control loop of program (while loop)
Analysis report on the development trend and Prospect of global and Chinese supercontinuum laser source industry Ⓚ 2022 ~ 2027