Trie 字典树(附数据生成程序)
题意很好懂,就问一堆单词两两比较要多少次。
不过很忧伤的是卡优化了。写了个数据生成,然后我跟别人程序比,用时大概是别人的一倍。
别人635ms 过了。我就TLE…… 问题是2000ms啊。给跪了。
附数据生成程序,各位可以生成数据看看,愿不要TLE。
#include
#include
#include
#include
#in...
分类:
其他好文 时间:
2014-07-18 23:14:02
阅读次数:
329
UVA 11892 - ENimEN
题目链接
题意:给定n堆石头,两人轮流取,每次只能取1堆的1到多个,如果上一个人取了一堆没取完,那么下一个人必须继续取这堆,取到最后一个石头的赢,问谁赢
思路:简单推理一下,后手只可能在堆数偶数并且都是1的情况下才可能赢
代码:
#include
#include
const int N = 20005;
int t, n,...
分类:
其他好文 时间:
2014-07-18 22:35:48
阅读次数:
197
Description
You have just finished a compiler design homework question where you had to find the parse tree of an expression. Unfortunately you left your assignment in the library, but lucki...
分类:
其他好文 时间:
2014-07-18 22:19:15
阅读次数:
249
UVA 10165 - Stone Game
题目链接
题意:给定n堆石子,每次能在一堆取1到多个,取到最后一个赢,问谁赢
思路:就裸的的Nim游戏,利用定理求解
代码:
#include
#include
int n, num;
int main() {
while (~scanf("%d", &n) && n) {
int sum = 0;
...
分类:
其他好文 时间:
2014-07-18 22:17:20
阅读次数:
342
Counting
The Problem
Gustavo knows how to count, but he is now learning how write numbers. As he is a very good student, he already learned 1, 2, 3 and 4. But he didn't realize yet tha...
分类:
其他好文 时间:
2014-07-18 22:04:36
阅读次数:
322
题目如下:
The Sultan's Successors
The Sultan of Nubia has no children, so she has decided that thecountry will be split into up to
k separate parts on her death andeach part wi...
分类:
其他好文 时间:
2014-07-18 22:00:59
阅读次数:
310
UVA 11927 - Games Are Important
题目链接
题意:给定一个有向图,结点上有一些石头,两人轮流移动石头,看最后谁不能移动就输了,问先手还后手赢
思路:求出每个结点的sg函数,然后偶数个石头结点可以不用考虑,因为对于偶数情况,总步数肯定能保证是偶数,所以只要考虑奇数情况的结点
代码:
#include
#include
#include ...
分类:
其他好文 时间:
2014-07-18 21:32:27
阅读次数:
224
UVA 12293 - Box Game
题目链接
题意:两个盒子,一开始一个盒子有n个球,一个只有1个球,每次把球少的盒子中球消掉,把多的拿一些球给这个盒子,最后不能操作的输(球不能少于1个),Alice先手,问谁赢
思路:博弈,题目其实可以转化为,给定一个n,每次把减少1到n/2的数字,最后谁是1谁就输了,那么可以去递推前几项找个规律,或者推理,都可以发现只要是2^i - 1...
分类:
其他好文 时间:
2014-07-18 21:27:44
阅读次数:
186
UVA 847 - A Multiplication Game
题目链接
题意:一个数一开始是1,每次轮流乘2-9,谁先大于n谁就赢,问谁胜
思路:博弈,找出必胜态,2-9为stan,10-18为ollie,19-162为stan...发现都是乘2乘9交替
代码:
#include
#include
#include
long long n;
bool ju...
分类:
其他好文 时间:
2014-07-18 21:27:15
阅读次数:
194
uva548:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=489题意:给出一颗二叉树的中序遍历和后序遍历,求一条路径,这条路径从根...
分类:
其他好文 时间:
2014-07-18 20:21:14
阅读次数:
205