考虑每张纸的SG:
我们称当前纸可以切成的两张纸ai,bi为当前纸的子状态
那么当前纸的SG就是它所有子状态的异或和
而它的每一个子状态有2张纸,也是求异或和
因为每张纸的属性包括w和h,所以用到二维数组保存sg值(当然结构体保存一张纸的属性也可)
#define mem(a,x) memset(a,x,sizeof(a))
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
#include<map>
#include<stdlib.h>
#include<cctype>
#include<string>
using namespace std;
typedef long long