一遍预处理跑完所有情况,O(1)回答就好。状态记录我用的康拓和逆康拓。#includeusing namespace std;int d[40320];int fac[8];int u[8];int cantor(){ int re = 0; for(int i = 0; i u[j])...
分类:
其他好文 时间:
2015-10-18 16:49:51
阅读次数:
185
QuestionThen-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all...
分类:
其他好文 时间:
2015-10-18 06:38:21
阅读次数:
280
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on...
分类:
其他好文 时间:
2015-10-06 14:04:44
阅读次数:
237
Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc...
分类:
其他好文 时间:
2015-10-06 12:54:25
阅读次数:
221
题目大意:立体的八数码问题,一次操作是滚动一次方块,问从初始状态到目标状态的最少滚动次数。题目分析:这道题已知初始状态和目标状态,且又状态数目庞大,适宜用双向BFS。每个小方块有6种状态,整个大方格有9*6^8个状态。每个小方块用一位6进制数表示即可。注意:状态转移时要谨慎,否则会出现意想不到的错误...
分类:
其他好文 时间:
2015-10-05 20:48:32
阅读次数:
268
有个2*N+1的线性的棋盘,开始时最左边全是白,右边全是黑,中间一个空格。目标是黑白全部互换。求输出最少步数的操作的棋子的下标。并且要字典序最小的。980ms险过。不判重700ms能过。我居然多此一举的用map判重。/*ID: modengd1PROG: shuttleLANG: C++*/#inc...
分类:
其他好文 时间:
2015-10-02 23:47:01
阅读次数:
259
卡片游戏 题目大意:给你一排卡片,你可以从从中抽一些卡片(但是不能抽最左和最右的卡片),每张卡片上有一个数字,当你从中抽出一张卡片后,你将得卡片的数字和卡片左右两张卡片的数字的乘积的分数,问当剩下最左和最右两张卡片的时候,你可...
分类:
其他好文 时间:
2015-10-02 21:11:50
阅读次数:
166
Problem:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all...
分类:
其他好文 时间:
2015-10-02 06:38:33
阅读次数:
193
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on...
分类:
其他好文 时间:
2015-09-29 06:36:18
阅读次数:
154
In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as th...
分类:
其他好文 时间:
2015-09-28 19:01:40
阅读次数:
236