hdu3404 Switch lights】的更多相关文章

题目描述 题解: 首先,由$SG$定理得SG(x,y)=mex(SG(x',y)^SG(x,y')^SG(x',y'))(x'<x,y'<y) 这里的$SG(x,y)$叫$Nim$积. $Nim$积满足交换律.结合律以及对$Nim$和(异或)的分配律. 代码: #include<cstdio> #include<cstring> int T,n; ][]; int nim_mul(int x,int y) { if(x<y)x^=y^=x^=y; &&am…
题意:在一个二维平面中,有n个灯亮着并告诉你坐标,每回合需要找到一个矩形,这个矩形xy坐标最大的那个角落的点必须是亮着的灯,然后我们把四个角落的灯状态反转,不能操作为败 思路:二维Nim积,看不懂啊,只能套模板了 参考:HDU 3404 Switch lights (NIM 积) 代码: #include<set> #include<map> #include<stack> #include<cmath> #include<queue> #inc…
http://acm.hdu.edu.cn/showproblem.php?pid=3404 题目 http://www.doc88.com/p-5098170314707.html 论文 nim积在22页附近 http://blog.csdn.net/kele52he/article/details/77099890 抄的代码的来源 根据论文相关部分和自己的理解的介绍.(nim积其实没什么卵用,学这种毒瘤的都有猫病.) nim和其实就是异或,想一下之前sg函数或者nim游戏结算的时候,是几堆在…
主要是求NIM积!!! 代码如下: #include<iostream> #include<cstdio> #include<stack> #include<cstring> #define ll __int64 using namespace std; ][]; int nim(int x,int y); int _nim(int x,int y){ <<x+y; int &F=f[x][y]; )return F; ,e=; ;i&l…
由于某毒瘤出题人 redbag 不得不学习一下这个史诗毒瘤算法. 本文参考了 Owaski 的 GameTheory 的课件. 定义 我们对于一些二维 \(\mathrm{Nim}\) 游戏(好像更高维也行),可以拆分成两维单独的 \(\mathrm{Nim}\) 然后求 \(\mathrm{Nim}\) 积. 定义为 \[ x \otimes y = \mathrm{mex}\{(a \otimes b) \oplus (a \otimes y) \oplus (x \otimes b), 0…
(Nim积相关资料来自论文曹钦翔<从"k倍动态减法游戏"出发探究一类组合游戏问题>) 关于Nim积计算的两个函数流程: 代码实现如下: ][]={,,,}; int Nim_Multi_Power(int x,int y) { ) return m[x][y]; ; for(;;a++) <<(<<a))&&x<(<<(<<(a+)))) break; <<(<<a); int p…
E. Danil and a Part-time Job time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher. Danil works in a rooted tree (undirected connected acyclic graph) with n vertices, vertex 1 is the root of the tree. There…
E. Danil and a Part-time Job 题目链接:http://codeforces.com/contest/877/problem/E time limit per test2 seconds memory limit per test256 megabytes Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he i…