当前位置:网站首页>[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;
}
边栏推荐
- Asynchronous artifact: implementation principle and usage scenario of completable future
- Décompiler et modifier un exe ou une DLL non source en utilisant dnspy
- Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
- Compréhension de la technologie gslb (Global Server load balance)
- Base ring tree Cartesian tree
- 2022-2-14 acwing1027 grid access
- Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
- 使用dnSpy对无源码EXE或DLL进行反编译并且修改
- 鹏城杯 WEB_WP
- TiDB 之 TiCDC6.0 初体验
猜你喜欢

gslb(global server load balance)技術的一點理解

Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)

Persistence of Nacos

How PHP adds two numbers

Covariance

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

2022 safety officer-a certificate registration examination and summary of safety officer-a certificate examination

The post-90s resigned and started a business, saying they would kill cloud database

MySQL - idea connects to MySQL
![[vulnhub shooting range] impulse: lupinone](/img/27/b92eeceefd1c71f19d926bdd1eee8b.jpg)
[vulnhub shooting range] impulse: lupinone
随机推荐
Idea shortcut word operation
JS Demo calcule combien de jours il reste de l'année
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
Is it safe and reliable to open an account and register for stock speculation? Is there any risk?
Under the double reduction policy, research travel may become a big winner
IPhone development swift foundation 09 assets
UC Berkeley proposes a multitask framework slip
What is the difference between res.send() and res.end() in the node express framework
(5) User login - services and processes - History Du touch date stat CP
Memory analyzer (MAT)
2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
90 后,辞职创业,说要卷死云数据库
Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
Tkinter Huarong Road 4x4 tutorial III
How PHP drives mongodb
How does sentinel, a traffic management artifact, make it easy for business parties to access?
Development trend and market demand analysis report of China's energy storage battery industry Ⓩ 2022 ~ 2028
Advanced technology management - how to examine candidates in the interview and increase the entry probability
pivot ROP Emporium
On my first day at work, this API timeout optimization put me down!