WA题
冒牌嘚小冬瓜
I'm nobody now, but,I''ll be somebody in the future每个人都有一个梦,我也有,所以,朝着要实现自己的那个梦的方向出发吧,我年轻我怕谁,This is me!
展开
-
并查集
这几天练习了并查集,解决多个集合问题。。 下面给一下模板int tp[1000];void init(){ for(int i = 1; i <= 100; i++) tp[i] = i; //初始化}int find(int x){ int t = x; while(t != tp[t])//找根节点原创 2015-07-19 20:44:09 · 433 阅读 · 0 评论 -
Autocomplete
Description Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new原创 2015-12-22 20:13:29 · 982 阅读 · 0 评论 -
Right Triangles
Description You are given a n × m field consisting only of periods (‘.’) and asterisks (‘‘). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are i原创 2015-12-18 11:23:27 · 543 阅读 · 0 评论 -
Fire Again
Description input input.txt output output.txt After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows with M trees each were planted and the rows were原创 2015-11-15 10:34:43 · 805 阅读 · 0 评论 -
Chess
Description Two chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other原创 2015-11-15 10:47:44 · 462 阅读 · 0 评论 -
并查集中的最小生成树
最小生成树————结构体 + 并查集 给一个例题:Constructing Roads Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other.原创 2015-07-19 20:47:48 · 501 阅读 · 0 评论 -
母牛的故事
斐波那契数列 先普及一下基础知识1.定义斐波那契数列,又称黄金数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、……在数学上,斐波纳契数列以如下被以递归的方法:F0=0,F1=1,Fn=F(n-1)+F(n-2)(n>=2,n∈N*).2.通项公式斐波那契数列:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,原创 2015-02-11 10:27:07 · 562 阅读 · 0 评论 -
递增
Description给你N个数,分别为a1,a2…aN,你现在可以交换两个数(只有一次机会),问你是否可以使这个序列成为递增序列。 即x1 <= X2 <= X3 <= X4.你只有一次交换机会,也可以选择不交换。Input输入包含多组测试用例,对于每组测试用例。 输入N(1 <= N <= 100000) 接下来输入N个数ai(0 <= ai <= 100000)。Output最多交换两个原创 2015-06-13 08:19:29 · 970 阅读 · 1 评论 -
重复出现的数字
Input输入有多组测试用例,对于每组测试用例: 输入一个整数N(N <= 106),随后输入N个整数Ni(0 < Ni <= 104)Output输出出现次数最多的数字和对应次数,如果出现次数最多的数有多个,输出数字最大的那个。Sample Input5 1 1 2 2 3 5 1 2 3 4 4 Sample Output2 2 4 2#include <stdio.h>#incl原创 2015-06-16 15:08:41 · 1196 阅读 · 0 评论 -
Autocomplete代码的修改
这道题在大神的帮助下终于找到错误了,原来是比较函数写错了。 改过后的代码#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;struct xx{ char qq[101];}x[101];int cmp(const void *x, const void *y){原创 2015-12-27 18:38:42 · 489 阅读 · 0 评论