当前位置:网站首页>[sg function]split game (2020 Jiangxi university student programming competition)
[sg function]split game (2020 Jiangxi university student programming competition)
2022-07-03 22:03:00 【HeartFireY】
At the beginning there was a n × m n \times m n×m Paper of , Then as the game goes on , You will get multiple pieces of mesh paper of different sizes , In this way, you can remember a piece of paper as a game , Each game constitutes the sum of a game . Each of these games is a directed graph game , But we have to find a situation where we can't act by ourselves . obviously 1 ∗ 2 1*2 1∗2 And 1 ∗ 3 1*3 1∗3( 2 ∗ 1 2*1 2∗1 and 3 ∗ 1 3*1 3∗1 Empathy ) Cannot split again , And other rectangles can be divided into one of the two , Therefore, these two situations are selected as the inevitable situation .
For one N × M N \times M N×M Rectangular grid paper , We can enumerate how to act , Then get two sub Games , For two sub Games S G SG SG Value is XOR , Then you get the corresponding after cutting SG value . For all the situations after cutting S G SG SG Value for m e x mex mex operation ( Record all values as a set , Returns the smallest number that does not exist in the set ) You can get the current paper SG value .
Be careful to avoid 1 × 1 1 \times 1 1×1 The situation of
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define win cout << "Alice" << endl
#define lose cout << "Bob" << endl
const int N = 200;
int sg[N][N];
void getsg(){
memset(sg, -1, sizeof(sg));
sg[1][1] = sg[1][2] = sg[2][1] = sg[1][3] = sg[3][1] = 0;
for(int i = 1; i <= N; i++){
for(int j = 1; j <= N; j++){
set<int> st;
for(int k = 1; k < i; k++){
int lx = k, ly = j;
int rx = i - k, ry = j;
if((lx == 1 && ly == 1) || (rx == 1 && ry == 1)) continue;
st.insert(sg[lx][ly] ^ sg[rx][ry]);
}
for(int k = 1; k < j; k++){
int lx = i, ly = k;
int rx = i, ry = j - k;
if((lx == 1 && ly == 1) || (rx == 1 && ry == 1)) continue;
st.insert(sg[lx][ly] ^ sg[rx][ry]);
}
int mex = 0;
while(st.count(mex)) mex++;
sg[i][j] = mex;
}
}
}
inline void solve(){
getsg();
int n, m;
while(cin >> n >> m){
if(sg[n][m]) win;
else lose;
}
}
signed main(){
solve();
return 0;
}
边栏推荐
- Compréhension de la technologie gslb (Global Server load balance)
- Luogu deep foundation part 1 Introduction to language Chapter 7 functions and structures
- On my first day at work, this API timeout optimization put me down!
- Is the account opening of Guotai Junan Securities safe and reliable? How to open Guotai Junan Securities Account
- Minio deployment
- Advanced technology management - how to examine candidates in the interview and increase the entry probability
- MySQL - index
- Investment analysis and prospect trend prediction report of China's boron nitride industry Ⓨ 2022 ~ 2028
- Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
- 常用sql集合
猜你喜欢
Persistence of Nacos
Compréhension de la technologie gslb (Global Server load balance)
使用dnSpy对无源码EXE或DLL进行反编译并且修改
Intimacy communication -- [repair relationship] - use communication to heal injuries
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)
How PHP adds two numbers
Redis concludes that the second pipeline publishes / subscribes to bloom filter redis as a database and caches RDB AOF redis configuration files
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
Electronic tube: Literature Research on basic characteristics of 6j1
随机推荐
Preliminary analysis of smart microwave radar module
Tidb's initial experience of ticdc6.0
regular expression
gslb(global server load balance)技術的一點理解
UC Berkeley proposes a multitask framework slip
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
QFileDialog
Analysis report on the development trend and Prospect of global and Chinese supercontinuum laser source industry Ⓚ 2022 ~ 2027
Plug - in Oil Monkey
Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
IPhone development swift foundation 09 assets
Awk getting started to proficient series - awk quick start
No matter how hot the metauniverse is, it cannot be separated from data
Conditional statements of shell programming
Persistence of Nacos
JS notes (III)
How does sentinel, a traffic management artifact, make it easy for business parties to access?
No more! Technical team members resign collectively
Leetcode problem solving - 235 Nearest common ancestor of binary search tree
2022-2-14 acwing1027 grid access