随笔分类 -  Acm

上一页 1 ··· 9 10 11 12 13 14 15 下一页
摘要:这题印象深刻,我刚接触acm时,以为这题是水题(因为是中文,又短),一直没做出。现再想想也是。可能也是我以前字符串掌握不好;这题其实也可以用stl里的map写。这里我用字典树写的。其实这题算简单题了吧。#include#include#includestruct trie{ trie *nex... 阅读全文
posted @ 2015-07-30 14:54 sweat123 阅读(267) 评论(0) 推荐(0)
摘要:比较简单,出现前缀。不过要释放空间。#include #include #include struct trie{ trie *next[10]; int sum;};trie *root;char str[10002][11];void init(){ root=(trie*)m... 阅读全文
posted @ 2015-07-30 13:40 sweat123 阅读(378) 评论(0) 推荐(0)
摘要:这题我开始想的简单了,WA一次,然后看disscuss里有人说输入时长度从小到大的,然后我信了。然后开始while(1) WA;然后我尝试先放如数组。后来对了;discuss里面果然不能太相信。根据出现的次数来判断是否为前缀。#include#include#includestruct trie{ ... 阅读全文
posted @ 2015-07-30 10:50 sweat123 阅读(347) 评论(0) 推荐(0)
摘要:#include#include#include#define maxn 26//26个字母 struct trie{ trie *next[maxn];//向下26个字母扩展 int v;//记录个数};trie *root;void init(){ root=(trie*)ma... 阅读全文
posted @ 2015-07-29 22:58 sweat123 阅读(111) 评论(0) 推荐(0)
摘要:这题让我第一次感受到了什么叫做在绝望中A题。这题我总共交了18次,TLE不知道几次,WA也不知道几次。这题不能用dijkstra,用这个我一直超时(我没试过dij+优先队列优化,好像优先队列优化后可以过).。用了我近一天的时间。。。。。。#include#include#includeusing n... 阅读全文
posted @ 2015-07-29 14:47 sweat123 阅读(398) 评论(0) 推荐(0)
摘要:开始的时候想的比较简单,直接枚举所有输入的边,但最后超时;后来就先进行一次dij,记录所有最短路上的边,然后枚举删去这些边;#include#include#define maxn 1002#define INF 99999999int map[maxn][maxn],vis[maxn],n,dis... 阅读全文
posted @ 2015-07-29 09:08 sweat123 阅读(324) 评论(0) 推荐(0)
摘要:网上有优化的方法 就是乘上一个一维的矩阵;现在还没有想通。想通了不上代码;我用的就是普通的矩阵,压着时间过;只是多了一个判断条件,不加这个条件就超时;#include#include#define INF 99999999#define maxn 85struct Mat{ int mat[m... 阅读全文
posted @ 2015-07-28 16:18 sweat123 阅读(220) 评论(0) 推荐(0)
摘要:建图还是有点烦人的。#include#include#include#include#include#define maxn 105#define INF 99999999using namespace std;int g[maxn][maxn],vis[maxn],dis[maxn],n;void... 阅读全文
posted @ 2015-07-28 14:24 sweat123 阅读(157) 评论(0) 推荐(0)
摘要:字符串问题。是否出现iPhone Apple等词;我考虑时想到既然是否有这些词,可以写map标记一下;然后又最长的是iPhone,6个单词,所以第一个for遍历所有单词然后在一个for(1~6),用string+c[];然后判断是否该单词被标记,如果被标记过,那就是需要的词,随后第一个for加上单词... 阅读全文
posted @ 2015-07-28 11:00 sweat123 阅读(262) 评论(0) 推荐(0)
摘要:比较简单的题 搜索4个方向,维护位子的值。#include#include#includeusing namespace std;int a[10],b[10];int vis[10][10][10][10][10][10];struct node{ int x1,x2,x3,x4,x5,x6... 阅读全文
posted @ 2015-07-28 10:52 sweat123 阅读(273) 评论(0) 推荐(0)
摘要:既然输入的是损坏率,那1-x就是剩余的。最后只要剩余的最大。#include#include#define Max 99999999const int maxn=1003;double dis[maxn],map[maxn][maxn];int vis[maxn],n,val[maxn];void ... 阅读全文
posted @ 2015-07-28 10:44 sweat123 阅读(164) 评论(0) 推荐(0)
摘要:2边SPFA 然后求和#include#include#include#define INF 1000000000#define ii __int64using namespace std;struct node{ ii v; ii val; ii next;}edge1[1000... 阅读全文
posted @ 2015-07-28 10:40 sweat123 阅读(295) 评论(0) 推荐(0)
摘要:floyd一遍即可。如果floyd后值有变大就是#include#include#include#include#include#define INF 99999999using namespace std;const int maxn=36;double mmap[maxn][maxn],val;... 阅读全文
posted @ 2015-07-28 10:37 sweat123 阅读(254) 评论(0) 推荐(0)
摘要:输入是2个不在一起的人,可以用一个数组来保存和他矛盾的人。这样find的时候就find(hash[]);就可以;#include#includeint pa[100020],h[100020],n;void init(){ for(int i=0;i<=n;i++) { p... 阅读全文
posted @ 2015-07-28 10:34 sweat123 阅读(197) 评论(0) 推荐(0)
摘要:比较恶心1: 0 0 空树是一棵树2: 1 1 0 0 不是树 3: 1 2 1 2 0 0 不是树...4: 1 2 2 3 4 5 不是树 森林不算是树5: 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 1 错6: 1 2 2 1 0 0 也是错误的#include#i... 阅读全文
posted @ 2015-07-28 10:31 sweat123 阅读(230) 评论(0) 推荐(0)
摘要:#include#include#includeusing namespace std;int main(){ int n,m,i,j; char name[10003][33],str[33]; string s1,s2; while(scanf("%d",&n)!=EOF... 阅读全文
posted @ 2015-07-28 10:22 sweat123 阅读(179) 评论(0) 推荐(0)
摘要:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1332#include#include#include#include#includeusing name... 阅读全文
posted @ 2015-07-28 10:20 sweat123 阅读(155) 评论(0) 推荐(0)
摘要:QueuesandPriority Queuesare data structures which are known to most computer scientists. TheTeam Queue, however, is not so well known, though it occur... 阅读全文
posted @ 2015-07-28 10:18 sweat123 阅读(128) 评论(0) 推荐(0)
摘要:题意:最小生成树的最大边最小,sort从小到大即可poj2485#include#include#includeusing namespace std;#define maxn 505int map[maxn][maxn],pa[150000],num,n;struct node{ int x... 阅读全文
posted @ 2015-07-28 09:44 sweat123 阅读(257) 评论(0) 推荐(0)
摘要:判断最小生成树是否唯一。kruskal时记录需要的边,然后枚举删除它们,每次删除时进行kruskal,如果值未变,表明不唯一。#include#include#include#includeusing namespace std;struct Node{ int l; int r; ... 阅读全文
posted @ 2015-07-28 09:28 sweat123 阅读(247) 评论(0) 推荐(0)

上一页 1 ··· 9 10 11 12 13 14 15 下一页