随笔分类 - ACM
摘要:首先要判断能否构成生成树,刚开始的思路是用hash遍历城市,看是否所有的城市都记录进取,被测试数据误导,如果给这组数据(1,2)(3,4)这么没办法构成单树。#include#includeconst int INF=0x7fffffff;const int MAXN=110;int hash[MA...
阅读全文
摘要:水题:还是wa了三次。主要问题是行数是n*(n-1)/2,刚开始没有审题,其次直接把结果存储在n里头,导致城市数目发生了改变#includeconst int MAXN=500;const int INF=0x7fffffff;int map[MAXN][MAXN];int dist[MAXN];i...
阅读全文
摘要:还是寻求father[i]=i代表几个集合,还有初始化MAXN不能有等于,Make_seth函数再次忘记写了#includeconst int MAXN=1010;int father[MAXN],rank[MAXN];void Make_set(){ for(int i=1;irank[y]...
阅读全文
摘要:#includeconst int MAXN=110;const int INF=0x7fffffff;int n;//几个城市int dist[MAXN];//dist[i]表示i向外延伸的最短边长int map[MAXN][MAXN];//储存a->b之间的边权值int pre[MAXN];//...
阅读全文
摘要:#include#includeconst int MAXN=10000010;int father[MAXN],hash[MAXN];void Make_set(){ for(int i=0;irank[y]) father[y]=x; else { if(rank...
阅读全文
摘要:判断树是否唯一1.只有一个根节点,(1)在一棵树上一个根节点。1 2 3 2就是两个根节点(1)只有一棵树2.不成环,入度不大于1由于数组运行超界导致wa,这是老毛病了 还一直错#includeconst int MAXN=1000100;int father[MAXN],rank[MAXN];st...
阅读全文
摘要:坑爹啊。。。 这道题不难但是还是wa了四次,首先该图必须连通的**,其次房间号码大小不一定从1开始,所以他的大小可以随意的,在初始化的时候需要将持续到MAXN,当直接输入0 0的时候输出的是YES,还有就是虽然集合合并后,但是father还不一定相同,必须Find后才能相同#includeconst...
阅读全文
摘要:题意:找几个不相连的团体,最后查找发现只要father有几个是自己的,就有几个团队,这个我没想到#include#includeconst int MAXN=1010;int father[MAXN],rank[MAXN];int hash[MAXN];void Make_set(int n){ ...
阅读全文
摘要:01dp不过由于数组过于大,开不开,学了搜索过了,先记录下 还有一种方法#include#includeusing namespace std;const int MAXN=10000010;int a[MAXN];int n,m,ans;bool cmp(int a,int b){ retu...
阅读全文
摘要:题意:求最大矩阵和将二维转化为一维的#include#includeint main(){ int n,i,j,k; int map[130][130],mSum[130]; while(scanf("%d",&n)!=EOF) { int max=-10000...
阅读全文
摘要:最大子窜和,用b记录当前的和,用sum记录最大的和,当bint main(){ int a[100010]; int T,i,b,sum,n,t1,t2; int cas=1,x; scanf("%d",&T); while(T--) { scanf...
阅读全文
摘要:We all love recursion! Don't we?Consider a three-parameter recursive function w(a, b, c):if a 20 or b > 20 or c > 20, then w(a, b, c) returns:w(20, 2...
阅读全文
摘要:从顶到底的最大和是多少#include#includeint main(){ int n,i,j; int a[110][100]; int sum[110]; int ans; while(scanf("%d",&n)!=EOF) { for (i...
阅读全文
摘要:uva的题真的很好,每个题都能长许多知识,A了后很开心,这道题我用了两天写,只一道题就学了四个函数,成长不少Problem E: Automatic EditingSource file:autoedit.{c,cpp,java,pas}Input file:autoedit.inOutput fi...
阅读全文
摘要:题意:给几个单词,在给几个句子,输出包含最多单词的那个句子,大小写不分,末尾空行分析:这道题能A,还是挺开心的,但不说多难,而是又学会了个函数,又知道了个细节 这题目还有个问题就是,单词的区分不仅仅靠空格还有其他非字母的符号都可以,如aa.aa 而对于我以前的思路,若ansans这是一个...
阅读全文
摘要:题目很简单,数组开大就好,5000但加上重复就不够了10000都小,sort排序前闭合后开,对二维字符窜排序用结构体,所以只有一组的时候只是本身但是不会出现RE情况,还有一点 “ ... a”这组数据,若不先判断掉前面的符号就存储, 输出的时候会 a有无谓...
阅读全文
摘要:英语太烂啊。In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well...
阅读全文
摘要:输出结束是EOF,这个害我wa,水题,二进制转换为ascii#include#include#includeint main(){ int i,j; int ans=0,tes; char str[100]; while(gets(str)!=NULL) { ...
阅读全文
摘要:题意:找相同字符窜首字母的地址读题。。。。A word matches a straight, uninterrupted line of letters in the grid.The outputs of two consecutive cases will be separated by a ...
阅读全文
摘要:题意:这道题我读了很久,也没有读懂最后看的解体报告才懂得题意,题目不难,但是还是错了两次,几个字符窜,左边的‘x’向右边移动当和右边的‘x’连接时候,求剩下的字符窜还有几个空格分析:这题错的原因是当吧B换成空格后scanf没有换成gets想当然的直接提交了,可定wa#include#includec...
阅读全文