- 博客(23)
- 资源 (2)
- 问答 (1)
- 收藏
- 关注
原创 URAL 1783 Nuclear Arms Race
Western and Eastern Cuckooland are close to the outbreak of war. Superpowers are competing for supremacy in nuclear warfare to achieve dominance in the military sphere. Unfortunately, production and
2013-05-30 01:19:15 827 1
原创 第十三周 problem A
How can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TROT to TORT:[i i i i o o o oi o i i o o i o]where i stands for Pus
2013-05-29 21:33:12 531
原创 第十三周训练 problem d
Problem DescriptionBackground The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves
2013-05-27 23:17:52 590
原创 hdu 2209 翻纸牌游戏 (双向bfs+位运算判重)
一看完题,果断bfs,然后写了个朴素的算法+map判重,然后judge得了个超时,把bfs改成了双向bfs,judge又给我个超内存,然后又把map改成了hash判重,又是超时。。。最后判重用了位运算,终于过去了。。。#include#include#include#include#include#include#includeusing namespace std;
2013-05-24 17:01:06 991 5
原创 hdu 3650 Hot Expo
最大子重叠即是答案,注意到同一时间不能出现在两个地方。#include#includeint c[1000000];int main(){ int n,b,a; while(scanf("%d",&n)&&n) { int max=-1; memset(c,0,sizeof(c)); for(int i=1;i<=n;i++) { scanf("%d%d",
2013-05-24 00:50:05 717
原创 hdu 1258 Sum It Up
很明显的dfs,input是按照非递减的顺序的,所以不用排序。麻烦之处在于怎样不输出重复的,比如 2 3 2 2 2 只需要输出一个2就够了#include#include#includeusing namespace std;int a[15],sum,n;bool vis[15];int flag;void out(){ int f=1; flag=1; for(
2013-05-24 00:45:08 587
原创 hdu 1050 Moving Tables (贪心)
就是求最大的子重叠数。问题在于应该是求走廊的重叠,而不是房间的重叠(1,2共用走廊1号,3,4共用走廊2号...)#include#includevoid swap(int &a,int &b){ int t=a; a=b; b=t;}int main(){ int t,n,a,b; scanf("%d",&t); while(t--) { int ans[5
2013-05-23 13:26:16 611
原创 hdu 1253 胜利大逃亡
一个三维的地图#include#include#includeusing namespace std;int map[55][55][55];bool vis[55][55][55];int a,b,c,time,ans;int dx[]={0,0,0,0,1,-1};int dy[]={-1,1,0,0,0,0};int dz[]={0,0,-1,1,0,0};struc
2013-05-22 17:12:15 546
原创 hdu 2717 Catch That Cow
#include#includeint q[100001];int dis[100001];bool vis[100001];int ans;int end;bool istrue(int x){ if(x>=0&&x<=100000&&!vis[x]) return 1; return 0;}void bfs(int start){ int front=1,rear=
2013-05-22 16:02:53 554
原创 hdu1518 dfs,回溯
TLE了好久!!唉……还是剪枝不到位啊。#include#include#includeusing namespace std;int a[25],n;int sum;int vis[25];bool dfs(int tot,int pos,int top) //pos记录位置,tot记录当前总数,top记录已经得到的边数{ if(tot==sum) if(t
2013-05-22 15:48:48 591
原创 hdu 1312 Red and Black
bfs搜到底,找到一个点就ans++#include#include#includeusing namespace std;int n,m;int map[25][25];bool vis[25][25];int sum;int dx[]={-1,1,0,0};int dy[]={0,0,-1,1};struct node{ int x; int y;};voi
2013-05-22 14:20:37 800
原创 hdu 2952 Counting Sheep(dfs)
类似八连块问题题意:如果上下左右其中有‘#’ 则它们属于一个羊群,只需对每一个格子dfs访问它的上下左右就行了。#include#includeint map[111][111];bool vis[111][111];int n,m;void dfs(int x,int y){ if(vis[x][y]||!map[x][y]) return; vis[x][y]=
2013-05-22 14:18:59 630
原创 poj 3615 Cow Hurdles
使最大的权值最小,一看到T的数据有4W多,就能想到答案是之前可以直接出来的。果断floyd思想,只不过每次松弛操作的是两条线路最大权值的最小值#include#includeint n,t;long map[305][305];inline long min(long a,long b){ return a<b?a:b;}inline long max(long a,lon
2013-05-22 00:46:39 570
原创 hdu 1242 Rescue (优先队列+bfs)
friend可能有多个 ("r" stands for each of Angel's friend. )但是主人公angel只有一个。所以可以从angel开始搜索,使用优先队列,时间小的优先级大。如果priority_queue是全局的,记得手动清空。#include#includeusing namespace std;int map[210][210];bool vis[
2013-05-19 18:17:19 537
原创 hdu 1548 A strange lift (bfs)
水bfs,也可以最短路做#include#includeint k[300];int q[100000];int dis[100000];int vis[101000];int b,n;int ans;void bfs(int cur){ int rear=1,front=1; q[rear++]=cur; vis[cur]=1; while(front<rear
2013-05-16 22:30:00 587
原创 hdu 1372 Knight Moves (水bfs)
马走日。#include#include#includeusing namespace std;int x2,y2;int ans;int q[100000];int dis[100000];int vis[10][10];int dx[]={-1,-2,-2,-1,1,2,2,1};int dy[]={2,1,-1,-2,-2,-1,1,2};void bfs(in
2013-05-16 21:56:16 670 2
原创 704 - Colour Hash(双向bfs)
写此题的时候头脑必须十分清晰,不然旋转函数非常容易写错。。。建议先写测试后再写搜索函数。16层,单向搜索的话时间空间开销都太大,可以采用正向8层,逆向8层的方式,如果相遇,则有解。#include#include#include#include#include#include#include#include#includeusing namespace std;s
2013-05-16 18:52:00 628
原创 Counterfeit Dollar hdu 1482 模拟题
有点小麻烦的模拟。#include#include#include#include#include#include#includeusing namespace std;int vis['Z'];int istrue['Z'];int main(){ int t,i,j; scanf("%d",&t); while(t--) { int min=0x3f
2013-05-15 01:09:22 835
原创 hdu2923 Einbahnstrasse map+floyd最短路
题意啊,题意很重要!!N第一个名字是拖车公司,后面的c个是破车的地方,所以有可能出现几个破车在同一个地方的。而拖车一次只能拖一辆,所以要用一个数组记录下每个破车的位置。就因为这,RE了我N次!建图过程也挺麻烦,主要是字符串的处理#include#include#include#include#includeusing namespace std;map m
2013-05-14 14:57:10 839
原创 hdu 1690 Bus System,(最短路)
普通的最短路,只是建图稍微麻烦点。最坑的地方是一定要用__int64存入数据。。。下面的代码可以用G++过,把%I64d改成%lld可以用C++过。#include#include#include#include#includeusing namespace std;const long long inf=0x3f3f3f3f3f3f3f3fLL;//4557430
2013-05-13 22:20:22 694
原创 10085 The most distant state(八数码,bfs+康拓判重)
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1026经典的八数码问题,此题是要求从已知状态能到达的最远状态。只需搜索到不能扩展结点为止,把最后一个结点输出就够了。路径可递归打印。判重可以用康拓展开#include#includ
2013-05-11 20:33:37 762
原创 10422 - Knights in FEN(bfs+map判重)
注意马的行走是按"日"字,其他的按照bfs搜就行了。因为少写了个句号调了我几个小时,郁闷!/*bfs搜索,map判重,因为第一次用map,代码有点乱,将就一下吧*/#include#include#include#include#include#includeusing namespace std;int dx[]={-2,2,-2,2,-1,1,-1,1};int
2013-05-10 20:34:45 632
原创 10603 - Fill,倒水问题 bfs解
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=110&page=show_problem&problem=1544#include#include#include#include#includeusing namespace std;int flag;
2013-05-09 20:31:29 682
为什么我的sublime的Preferences变成了灰色不可选
2016-07-17
TA创建的收藏夹 TA关注的收藏夹
TA关注的人