当前位置:网站首页>[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;
}
边栏推荐
- Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027
- Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
- [dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)
- 常用sql集合
- DOM light switch case
- 十大券商开户注册安全靠谱吗?有没有风险的?
- How to store null value on the disk of yyds dry inventory?
- 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
- How does sentinel, a traffic management artifact, make it easy for business parties to access?
- Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
猜你喜欢

Yiwen teaches you how to choose your own NFT trading market

QFileDialog

Compréhension de la technologie gslb (Global Server load balance)

treevalue——Master Nested Data Like Tensor

2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
![[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)](/img/6c/2d48d441fee1981a271319fd9f6c23.jpg)
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)

(5) User login - services and processes - History Du touch date stat CP

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)

Decompile and modify the non source exe or DLL with dnspy

Why use pycharm to run the use case successfully but cannot exit?
随机推荐
Leetcode problem solving - 235 Nearest common ancestor of binary search tree
[SRS] build a specified version of SRS
Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
js demo 计算本年度还剩下多少天
内存分析器 (MAT)
JS closure knowledge points essence
How to install sentinel console
Go language slice interview real question 7 consecutive questions
Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Collections SQL communes
Notes on MySQL related knowledge points (startup, index)
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
2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
How PHP drives mongodb
Nacos common configuration
[vulnhub shooting range] impulse: lupinone
How PHP adds two numbers
On my first day at work, this API timeout optimization put me down!