
ACM题
文章平均质量分 60
Bupt_Tornado
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
排序 UVA 10041 Vito's Family
题目衔接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=982属于简单题,代码如下:#include #include #include using namespace std;#define maxn 500+10int data原创 2013-04-22 22:44:16 · 732 阅读 · 0 评论 -
湖南师范大学第四届大学生计算机程序设计竞赛练习
关系Time Limit: 3000ms, Special Time Limit:7500ms, Memory Limit:65536KBTotal submit users: 34, Accepted users: 29Problem 11312 : No special judgementProblem description 在多原创 2013-06-17 11:22:42 · 1255 阅读 · 0 评论 -
湖南师范大学第四届大学生计算机程序设计竞赛练习
缺失的数字Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KBTotal submit users: 50, Accepted users: 49Problem 11314 : No special judgementProblem description原创 2013-06-17 11:25:17 · 1007 阅读 · 0 评论 -
湖南师范大学第四届大学生计算机程序设计竞赛练习
蛇形矩阵Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KBTotal submit users: 44, Accepted users: 44Problem 11315 : No special judgementProblem description原创 2013-06-17 11:26:20 · 1142 阅读 · 0 评论 -
poj 2001 shortest prefix
前缀树的简单应用,我的思路是每次加入单词是,为每个节点记录一个value,该value代表经过该节点的单词数目,每次取最短前缀时,只需要沿着单词查找第一个value值为1的节点,即表示只有该单词经过该节点。C++写的代码,有点啰嗦..0MS AC#include #include using namespace std;#define max_words 1100原创 2013-06-07 20:46:05 · 587 阅读 · 0 评论 -
poj 1328 Radar Installation
#include #include #include #include using namespace std;#define maxn 1000+10typedef struct pos{ double left; double right;}pos; //记录每个岛屿的圆心左边界和右边界pos position[maxn];原创 2013-06-09 14:37:41 · 483 阅读 · 0 评论 -
poj find the multiple
题目大意:给定一个数,求该数的一个倍数,该倍数满足十进制表示时只包括0和1.使用宽度优先搜索,使用的暴力搜索,使用queue会超时,自己实现一个简易队列就行。#include using namespace std;long long bfs(int x){ long long store[1000000]; int start = 0,rear = 1; store原创 2013-06-19 20:05:12 · 622 阅读 · 0 评论 -
poj 1159 palindrome
/*busyfisher 2013/6/20动态规划dp[i][j] 表示以str[i]开始以str[j]结束的子字符串称为回文需要加入的最少字符数递推式如下:Memory: 40756K Time: 1485MSLanguage: C++ Result: Accepted*/#include #include using namespace std;原创 2013-06-20 09:59:13 · 539 阅读 · 0 评论 -
poj 1836 Aligment
/*busyfisher 2013/6/19poj 1836 Alignment动态规划,最长递增子序列分别前后计算最长递增子序列,注意考虑前后有相同身高的情况测试数据:3 4 5 1 2 5 4 323 4 5 4 30*/#include using namespace std;#define maxn 1000+10float data[m原创 2013-06-19 23:07:18 · 659 阅读 · 0 评论 -
poj 3176 cow bowling
/*//// main.cpp// cow bowling//// Created by busyfisher on 13-6-20.// Copyright (c) 2013年 busyfisher. All rights reserved.// 位置图: 0 0 1 0 1 2 0 1 2原创 2013-06-20 16:18:02 · 535 阅读 · 0 评论 -
poj 1979 red and black
#include #include #define maxn 21char map[maxn][maxn];int result[maxn][maxn];int w,h;int main(){ while(scanf("%d %d",&w,&h) && w && h){ memset(result,0,sizeof(result)); for(int i = 0;i原创 2013-06-20 19:38:55 · 642 阅读 · 0 评论 -
poj 2013 Symmetric Order
#include #include using namespace std;string data[20];int main(){ int n; int count = 1; while(cin>> n && n){ for(int i =1;i<=n;i++){ cin>>data[i]; } int index[20]; //原创 2013-06-20 20:03:53 · 528 阅读 · 0 评论 -
poj 1207 3n+1
#include int count(int x){ int value = 0; if(x == 1) return 1; else { while(x != 1) { if(x%2 == 0) x /=2; else x = 3*x + 1; value++; } } return value+1;}int main()原创 2013-06-20 18:55:30 · 540 阅读 · 0 评论 -
poj 1007 DNA sorting
/*DNA sortingTAGS: STL MAPMemory: 276K Time: 32MSLanguage: C++ Result: Accepted*/#include #include #include #include using namespace std;#define maxn 110string data[maxn];multima原创 2013-06-23 17:47:29 · 539 阅读 · 0 评论 -
poj 1330 nearest common ancestor
/*busyfisher 2013/6/23poj 1330 nearest common ancestor用数组分别记录节点到根节点的路径,找出两个数组中,第一个相同的元素Memory: 364K Time: 141MSLanguage: C++ Result: Accepted*/#include #include using namespace std;原创 2013-06-23 19:46:25 · 539 阅读 · 0 评论 -
save
#include using namespace std;bool is_magic(int n){ bool is_four = false; int count = 0; while(n/10){ int t = n%10; if(t == 1){ is_four = false; count = 0; } else if(t == 4){ is原创 2013-06-23 22:21:31 · 606 阅读 · 0 评论 -
poj 2593 max sequence
/*busyfisher 2013/6/25poj 2593 max sequence动态规划:分别求出从左到右顺序数组的最大子数组和从右到左顺序数组的最大子数组; ans = max{dp_left[i]+dp_left[i+1] | 1<=i<N}Memory: 1432K Time: 204MSLanguage: C++ Result: Accepted*原创 2013-06-25 21:11:45 · 640 阅读 · 0 评论 -
poj 1321 棋盘问题
深度优先搜索代码:#include #include using namespace std;int n,k;char array[10][10]; //to record the chessboardbool visited[10]; //to record each line's statusint ans ;int sum ;void dfs原创 2013-06-06 22:53:28 · 531 阅读 · 0 评论 -
1840 poj Eqsa
对于数学表达式,ai,xi的范围[-50,50]且x不能为0,将表达式变型为时间复杂度O(10^6)#include using namespace std;int coe[5];short ans[40000000];int main(){ int result=0; for(int i=0;i<5;i++) cin>>coe[i]; for(int原创 2013-06-14 22:55:07 · 8974 阅读 · 0 评论 -
模拟 poj 1068 Parentcoding
题目衔接:http://poj.org/problem?id=1068题目大意:序列S是一个正确的括号匹配的序列; 序列P表示第i个匹配的右括号左边存在Pi个左括号 序列W表示第i非匹配括号对中包含Pi个匹配括号对AC代码:#include #include using namespace std;#define maxn 41char paren原创 2013-04-25 10:44:20 · 547 阅读 · 0 评论 -
宽度优先搜索 UVA 10150 Doublets
题目衔接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1091题目大意:定义两个单词为doublet序列,当两个序列的长度相同,且只有一个字母不相同,给出一个单词库,求两个单词之间可以通过doublet序列转化的路径。思路:开始想到了宽度优先搜索原创 2013-04-25 11:00:06 · 1043 阅读 · 0 评论 -
暴力穷举 poj Blue Jeans
直接用暴力法穷举所有情况#include #include #include using namespace std;string str[11];int main(){ int T; cin>>T; while(T--) { int n; cin>>n; for(int j=0;j<n;j++) cin>>str[j]; string resu原创 2013-04-25 20:37:44 · 601 阅读 · 0 评论 -
水题 poj Y2K Accounting Bug
题目衔接:http://poj.org/problem?id=2586题目大意:我是上网查了之后才明白的。题目的关键在于,财报的发布是5个月一次,而且每个月的盈余和赤字的两个数据是一样的,且题目中的条件为每5个月的财报都是赤字,可以根据下图理解:根据贪心策略,肯定是盈余的月数越多,总的盈余越大,则最好的情况就是每5个月中有一个月赤字(1/5),选取图中任意同颜色的一对即可,原创 2013-04-27 19:27:11 · 477 阅读 · 0 评论 -
排列组合 poj Paths on a grid
题目衔接:http://poj.org/problem?id=1942题目分析:组合数学问题,但是由于题目给的数据的范围比较大,所以不能用动态规划做,直接暴力解决,用double存放结果代码:Memory: 744KTime: 0MSLanguage: G++Result: Accepted#include #include using namespace std;原创 2013-04-30 20:20:07 · 436 阅读 · 0 评论 -
动态规划题 UVA Prince and Princess
题目衔接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1576题目大意:就是求两个序列的公共子序列,题目的特点是序列无重复元素。思路:这道题一看就是动态规划题,可得递推公式: 开始考虑用二维数组存储结果,但是题目中,250*250=625原创 2013-04-21 20:24:00 · 562 阅读 · 0 评论 -
poj 3126 Prime path
题目衔接:http://poj.org/problem?id=3126题目大意:对一个4位数进行变换,每次只能变一个数字,求变化到另一数字的最小变换数,注意第一位不能为0,用宽度优先搜索,第一次找到该数字时,即为最小变换次数代码如下:#include #include #include using namespace std;#define maxn 10原创 2013-05-17 16:46:56 · 499 阅读 · 0 评论 -
不相交集合 poj 1703 find them catch them
题目衔接:http://poj.org/problem?id=1703题目大意:一个囚犯可能属于A牢,可能属于B牢,给出每个不属于同一囚牢的条件,判断两个囚犯是否属于一个囚牢;思路:使用并查集数据结构,由于只有两个囚牢,与同一个囚犯不是一个囚牢的囚犯必然属于同一个囚牢,相同囚牢的囚犯归并带一个集合,同时记录与囚犯处于不同囚牢的囚犯集合,还是看代码吧.#include #include原创 2013-05-06 16:30:44 · 587 阅读 · 0 评论 -
poj 2503 babelfish
题目比较简单,但是输入比较纠结,我是用getline函数获取一行,再处理的,可以判断字符是否为空格来分开,我直接用sstream处理了,有点小题大做,用时比较多;使用map比较方便Memory: 9620K Time: 1813MSLanguage: C++ Result: Accepted#include #include #include #include #inc原创 2013-05-06 22:51:19 · 492 阅读 · 0 评论 -
poj 2253 frogger
题目衔接:http://poj.org/problem?id=2253题解:求出图中两点所有路径中权值最大数中的最小值,即可简化为求最小生成树中的距离最大值AC代码:Memory: 584K Time: 16MSLanguage: C++ Result: Accepted#include #include #include #include #include原创 2013-05-20 22:21:44 · 475 阅读 · 0 评论 -
动态规划 poj 2479 1458
两个基本题,求和最大的子数组和最长公共子串,应该熟练掌握这两种类型的动态规划最优解代码如下: Common Subsequence#include #include #include #include #include using namespace std;#define max_length 1000int result[max_length][max_lengt原创 2013-05-22 20:31:28 · 523 阅读 · 0 评论 -
BFS poj Catch that cow
题目衔接:http://poj.org/problem?id=3278代码:#include #include #include using namespace std;#define maxn 200000+10int data[maxn];bool visited[maxn];queue store;int bfs(int N,int K){ while(!sto原创 2013-05-09 19:46:00 · 482 阅读 · 0 评论 -
POJ Argus
该题的归类是归并排序,我用的是STL中的MAP,算是MAP的运用吧;题目衔接:http://poj.org/problem?id=2051题目大意:有若干查询,每一个查询都有查询号和间隔时间,求从开始时刻的前K个查询的编号,我的做法是先将所有的查询都放在map中,每次取第一个pair,以及键值和第一个pai相同的pair,即同一时刻发生的所有查询,并将该查询的下一次查询时间加入map中,最原创 2013-05-24 12:24:33 · 671 阅读 · 0 评论 -
poj 1797 Heavy Transportation
#include #include #include #include using namespace std;#define maxn 1000+10int nodes,edges;int weight[maxn][maxn];bool visited[maxn];int dis[maxn];int dij(int start){ for(int i=1;i<=nod原创 2013-05-28 11:00:39 · 519 阅读 · 0 评论 -
poj 2533 Longest Order Sequence
基础的最长递增子序列,递推式代码如下,时间复杂度O(n*n)#include using namespace std;#define maxn 1000+10int data[maxn];int dp[maxn];int main(){ int num; cin>>num; for(int i=1;i<=num;i++) cin>>data[i]; d原创 2013-05-30 10:18:12 · 441 阅读 · 0 评论 -
poj 2485 Highways
最小生成树的应用,之前用过prim算法实现,现在用kruskal算法实现,用并查集;开始的时候一直runtime error,是数组开的小的原因AC代码如下:#include #include #include #include using namespace std;#define maxn (500+500)typedef struct node{ in原创 2013-06-14 21:09:43 · 521 阅读 · 0 评论 -
北邮ACM推荐50题
北邮ACM推荐50题POJ推荐50题1、标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉。2、标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目。3、列表中大约有70个题目。大家选做其中的50道,且每类题目有最低数量限制。4、这里不少题目在BUPT ACM FTP上面都有代码,转载 2013-06-25 19:29:31 · 889 阅读 · 0 评论