【poj1041】 John's trip】的更多相关文章

http://poj.org/problem?id=1041 (题目链接) 题意 给出一张无向图,求字典序最小欧拉回路. Solution 这鬼畜的输入是什么心态啊mdzz,这里用vector储存边,便于边的排序.瞬间变成STL常数boy →_→. 细节 数组大小把握好. 代码 // poj1041 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #incl…
优先级队列+BFS. #include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; #define MAXN 25 typedef struct node_st { int x, y, t; node_st() {} node_st(int xx, int yy, int tt) { x = xx; y = yy; t = tt;…
博弈论 一看题,哇这不是Nim游戏么= =直接异或起来……啊咧怎么不对? 这道题是[Anti-Nim],普通的Nim是取走最后一个就赢,这题是取走最后一个输…… 做法参见 2009年贾志豪论文<组合游戏略述——浅谈SG游戏的若干拓展及变形> /************************************************************** Problem: 1022 User: Tunix Language: C++ Result: Accepted Time:16…
题目 John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple who get married on that day will be forever blessed by the God of Love. This year N couples plan to g…
Portal -->bzoj1022 Solution ​  这题其实是裸的反Nim,这里主要是为了写反Nim游戏的证明 ​  首先给出反Nim(anti-nim)的定义和结论: [定义]桌子上有 N 堆石子,游戏者轮流取石子: 每次只能从一堆中取出任意数目的石子,但不能不取:取走最后一个石子者败 [结论]先手必胜当且仅当满足下面两个条件中的一个 ​  (1)所有堆的石子数都为\(1\)且游戏的\(sg\)值为\(0\) ​  (2)有些堆的石子数大于\(1\)且游戏的\(sg\)值不为\(0\…
http://www.lydsy.com/JudgeOnline/problem.php?id=1022 好神的博弈论. 题解见dzy的blog:http://dzy493941464.is-programmer.com/posts/39629.html orz 题目1:有n堆石子,第i堆有A(i)颗石子.两人依次从中拿取,规定每次只能从一堆中取若干根,可将一堆全取走,但不可不取,最后取完者为胜,求必胜的方法. 令C=A(1) xor A(2) xor A(3) xor ... xor A(n)…
题目 John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple who get married on that day will be forever blessed by the God of Love. This year N couples plan to g…
[题解]POJ1934 Trip (DP+记录方案) 题意: 传送门 刚开始我是这么设状态的(谁叫我DP没学好) \(dp(i,j)\)表示钦定选择\(i\)和\(j\)的LCS,然而你会发现这样钦定没什么用. 还不如当时初学者的时候的\(dp(i,j)\)表示考虑到\(i\)考虑到\(j\)的LCS...果然经典的是禁得起考验的... 考虑如何记录方案,第一个想法是直接暴力记录从哪转移的,但是这样显然不行.因为有很多重复的元素. 注意到题目保证本质不同的满足答案要求的串的个数是\(O(n)\)…
John's trip Language:Default John's trip Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11092 Accepted: 3796 Special Judge Description Little Johnny has got a new car. He decided to drive around the town to visit his friends. Johnny wante…
http://codeforces.com/contest/811/problem/C [题意] 给定一个自然数序列,在这个序列中找出几个不相交段,使得每个段的异或值之和相加最大. 段的异或值这样定义:段中每个不同数字(不重复)相异或. 段有这样的要求:段中任意一个数字不会在段外出现. [思路] 首先预处理每个数字第一次出现和最后一次出现的位置,这样对于一个区间[l,r]就很容易判断是否为满足题意的段. 然后区间DP,dp[i]表示子序列[1,i]的最大值. 状态转移:对于dp[i],最小值为d…