Trie 字典树(附数据生成程序)
题意很好懂,就问一堆单词两两比较要多少次。
不过很忧伤的是卡优化了。写了个数据生成,然后我跟别人程序比,用时大概是别人的一倍。
别人635ms 过了。我就TLE…… 问题是2000ms啊。给跪了。
附数据生成程序,各位可以生成数据看看,愿不要TLE。
#include
#include
#include
#include
#in...
分类:
其他好文 时间:
2014-07-18 23:14:02
阅读次数:
329
UVA - 10895
Matrix Transpose
Time Limit:3000MS
Memory Limit:Unknown
64bit IO Format:%lld & %llu
[Submit] [Go Back] [Status]
Description
A: Matrix Transp...
分类:
其他好文 时间:
2014-07-18 23:00:14
阅读次数:
241
UVA 11892 - ENimEN
题目链接
题意:给定n堆石头,两人轮流取,每次只能取1堆的1到多个,如果上一个人取了一堆没取完,那么下一个人必须继续取这堆,取到最后一个石头的赢,问谁赢
思路:简单推理一下,后手只可能在堆数偶数并且都是1的情况下才可能赢
代码:
#include
#include
const int N = 20005;
int t, n,...
分类:
其他好文 时间:
2014-07-18 22:35:48
阅读次数:
197
UVA 11534 - Say Goodbye to Tic-Tac-Toe
题目链接
题意:给定一个序列,轮流放XO,要求不能有连续的XX或OO,最后一个放的人赢,问谁赢
思路:sg函数,每一段...看成一个子游戏,利用记忆化求sg值,记忆化的状态要记录下左边和右边是X还是O即可
代码:
#include
#include
const int N = 105;...
分类:
数据库 时间:
2014-07-18 22:34:57
阅读次数:
434
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 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