
题解
文章平均质量分 68
LucienShui
因为孤独是人之常态,所以陪伴才显得格外可贵。
展开
-
HDU 1233 - 还是畅通工程 - 最小生成树
HDU 1233 - 还是畅通工程 - 最小生成树 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-原创 2017-05-23 17:08:37 · 332 阅读 · 0 评论 -
畅通工程再续 - HDU 1875 - 最小生成树
畅通工程再续 - HDU 1875 - 最小生成树 相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于原创 2017-05-23 17:50:31 · 310 阅读 · 0 评论 -
敌兵布阵 - HDU 1166 - 线段树
敌兵布阵 - HDU 1166 - 线段树 C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。原创 2017-05-23 18:02:04 · 287 阅读 · 0 评论 -
I Hate It - HDU 1754 线段树
I Hate It - HDU 1754 线段树 国际惯例中文题目不需要解释题意。 思路:也是个水体,直接裸线段树就可以,没有什么需要注意的地方。写的时候有一个小错误就是刚开始我在本地运行的时候发现Q 1 5一直是零,结果发现是build函数没有写到main里去。AC代码://// main.cpp// L//// Created by LucienShui on 2017/5/2原创 2017-05-24 11:13:05 · 323 阅读 · 0 评论 -
A Simple Problem with Integers - POJ 3468 - 线段树 区间更新
A Simple Problem with Integers - POJ 3468 - 线段树 区间更新 You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each numbe原创 2017-05-26 09:42:14 · 450 阅读 · 0 评论 -
Just a Hook - HDU 1698 - 线段树
Just a Hook - HDU 1698 - 线段树题目: In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are原创 2017-05-28 11:03:54 · 506 阅读 · 0 评论 -
Color the ball - HDU 1556 - 线段树 区间更新单点查询
Color the ball - HDU 1556 - 线段树 区间更新单点查询 国际惯例中文题目不解释,思路直接裸线段树,Lazy思想入门题。 Lazy传送门:延迟更新详解AC代码://// main.cpp// L//// Created by LucienShui on 2017/5/28.// Copyright © 2017年 LucienShui. All righ原创 2017-05-28 11:22:20 · 634 阅读 · 0 评论 -
Balanced Lineup - POJ 3264 - 线段树
Balanced Lineup - POJ 3264 - 线段树 For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with原创 2017-05-28 16:10:01 · 379 阅读 · 0 评论 -
Can you answer these queries? - HDU 4027 - 线段树
Can you answer these queries? - HDU 4027 - 线段树题目: A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Ea原创 2017-05-28 17:13:06 · 552 阅读 · 0 评论 -
POJ 1679 - The Unique MST - 次小生成树
POJ 1679 - The Unique MST - 次小生成树 Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A原创 2017-05-23 16:44:25 · 394 阅读 · 0 评论 -
POJ 1258 Agri-Net 最小生成树
POJ 1258 Agri-Net 最小生成树 题意:有n个点,给你一个方阵代表他们两两之间的距离,求最小生成树。 思路:大水题,直接prim解决。AC代码://// main.cpp// L//// Created by LucienShui on 2017/5/11.// Copyright © 2017年 LucienShui. All rights reserved.原创 2017-05-21 17:42:50 · 304 阅读 · 0 评论 -
约会安排 - HDU 4553 - 线段树 - 区间合并
约会安排 - HDU 4553 - 线段树 - 区间合并思路 国际惯例中文题目直接说思路,DS QT:找一段最靠前长度为QT的空间;NS QT:找一段最靠前长度为QT的空间,如果没有找到可以将DS占据的空间当做空闲空间,找一段最靠前的空间;STUDY!! L R:清空[L,R]区间的空间。 用两个线段树,一个记录DS,一个记录NS,维护最大左区间ma_l,最大右区间ma_r,以及区间内最大区间m原创 2017-06-04 11:09:46 · 585 阅读 · 0 评论 -
Assign the task - HDU 3974 - 树 - 简单并查集
Assign the task - HDU 3974 - 树 - 简单并查集题目: There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If y原创 2017-06-01 17:45:29 · 378 阅读 · 0 评论 -
Transformation - HDU 4578 - 线段树
Transformation - HDU 4578 - 线段树题目描述: Yuanfang is puzzled with the question below: There are n integers, a 1, a 2, …, a n. The initial values of them are 0. There are four kinds of operations. Opera原创 2017-06-02 19:54:22 · 711 阅读 · 0 评论 -
Vases and Flowers - HDU 4614 - 线段树
Vases and Flowers - HDU 4614 - 线段树题目描述: Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them原创 2017-06-04 09:51:22 · 399 阅读 · 0 评论 -
ACM Contest and Blackout - UVA 10600 - 次小生成树
ACM Contest and Blackout - UVA 10600 - 次小生成树题意 n个点,m条边,求最小生成树的值和次小生成树的值。思路 无脑写次小生成树就OK,因为比较简单我就尝试着用Kruskal写了一下,本以为耗时会很长的,结果是0ms,感觉可能是数据水的原因。代码//// main.cpp// L//// Created by LucienShui on 201原创 2017-07-03 12:32:39 · 388 阅读 · 0 评论 -
Is There A Second Way Left? - UVA 10462 - 次小生成树
Is There A Second Way Left? - UVA 10462 - 次小生成树题意 判断是否有最小生成树,次小生成树,如果有次小生成树,则输出次小生成树的总权值。思路 题意很简单,思路也很直接,无脑写就可以。没想出来prim有什么比较简单的写的方法,用Kruskal写的。代码//// main.cpp// L//// Created by LucienShui on原创 2017-07-03 13:28:52 · 395 阅读 · 0 评论 -
Teen Girl Squad - UVA 11183 - 最小树形图
之前的两题次小生成树的题解一直没补,容我再拖一拖。(手动/doge)题目 PDF题目直接附上链接吧:传送门题意 很裸的最小树形图题目,直接套模板就可以。实现 这道题WA了很多遍因为没有注意到数据范围的问题,数组刚开始给小了。而且OJ一直给我返WA而不是RE之类的,让我很费解。 值得注意的一点是,在找环的过程中,我原本的代码是:for(int i=0 ; i<n ; i++) {//标记每个环原创 2017-07-14 16:03:35 · 561 阅读 · 0 评论 -
Command Network - POJ 3164 - 最小树形图
题目: http://poj.org/problem?id=3164题意: 裸最小树形图,套模板就可以。代码:#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;#define maxn 107#define memset(原创 2017-07-14 16:07:36 · 328 阅读 · 0 评论 -
Ice_cream’s world II - HDU 2121 - 最小树形图
Ice_cream’s world II - HDU 2121 - 最小树形图题目 http://acm.hdu.edu.cn/showproblem.php?pid=2121题意 给你n个点和m条有向边,问最少能花费多少将它们连起来,如果能连起来输出需要的权值和根的序号,不能的话输出impossible。思路 不定根最小树形图,虚拟出一个树根出来,令这个树根到每个点的权值为大于所有边的权值之原创 2017-07-15 00:33:40 · 414 阅读 · 0 评论 -
Transfer water - HDU 4009 - 最小树形图
题目 http://acm.hdu.edu.cn/showproblem.php?pid=4009题意 给定n个点的三维坐标,以及根节点到每个点的单向权值,再给定n个节点间相互单向连接的成本,求最小树形图。 思路 直接根据题意建图然后跑最小树形图模板,网上有人说这个题必定有解我觉得说法是错的,因为有些时候两点之间未必可以链接。过程 因为对模板不是很熟WA了很多发也DeBug了很久,发现是找完原创 2017-07-16 02:04:20 · 333 阅读 · 0 评论 -
Mayor's posters - POJ 2528 - 线段树 + 离散
Mayor’s posters - POJ 2528 - 线段树 + 离散 前言:这道坑爹题花了我一天的时间去理解,卡在离散和更新那里,无论怎样都想不明白。最后花了张图,这才终于明白原理。 题目: The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign原创 2017-05-28 00:03:43 · 372 阅读 · 0 评论 -
Paired Up - UPCOJ 3450
题目:题目描述 Farmer John finds that his cows are each easier to milk when they have another cow nearby for moral support. He therefore wants to take his M cows (M≤1,000,000,000, M even) and partition them原创 2017-07-30 00:08:23 · 1247 阅读 · 0 评论 -
奶牛的编号 - UPCOJ 3578
题目:题目描述 有N(1≤N≤1000)头奶牛,它们都被标上一个优先等级编号:1,2或3。用来表示它们喝水时的优先次序,编号为l的最优先,编号为2的其次,编号为3的最后。每天奶牛开始时排成一行,但总是很乱,需要你把它们重新排成编号为1的奶牛在最前面,编号为2的其次,编号为3的奶牛在最后。你能计算出最少需要多少的交换次序来完成这次重排吗?输入 第1行:1个整数N; 第2至N+I行:第i+l行有一原创 2017-07-30 00:17:30 · 3743 阅读 · 0 评论 -
Bovine Genomics - UPCOJ 3451 - 简单哈希 + 暴力
题目:题目描述 Farmer John owns N cows with spots and N cows without spots. Having just completed a course in bovine genetics, he is convinced that the spots on his cows are caused by mutations in the bovine原创 2017-07-30 00:26:28 · 476 阅读 · 0 评论 -
Hoof, Paper, Scissors - UPCOJ 3426 - 三维动态规划DP
题目:题目描述 You have probably heard of the game “Rock, Paper, Scissors”. The cows like to play a similar game they call “Hoof, Paper, Scissors”. The rules of “Hoof, Paper, Scissors” are simple. Two cows原创 2017-07-28 01:50:41 · 619 阅读 · 0 评论 -
小 Q 的棋盘 - UPCOJ 3779 - DFS + 贪心
链接 http://exam.upc.edu.cn/problem.php?id=3779题目:题目描述 小Q正在设计一种棋类游戏。在小Q设计的游戏中,棋子可以放在棋盘上的格点中。某些格点之间有连线,棋子只能在有连线的格点之间移动。整个棋盘上共有V个格点,编号为0,1,2…,V-1,它们是连通的,也就是说棋子从任意格点出发,总能到达所有的格点。小Q在设计棋盘时,还保证棋子从一个格点移动到另外任一原创 2017-08-01 16:47:10 · 467 阅读 · 0 评论 -
match - UPCOJ 3639 - 枚举 + 暴力
链接: http://exam.upc.edu.cn/problem.php?id=3639题目:题目描述小 x 在解说 F7 决赛时的搭档是韩乔生,以至于小 x 没有任何能说上话的机会。无聊的他玩起了填字游戏。一个 3*3 的九宫格里,每个格子里都被填上了一个字母,从而我们得到了 6 个单词。现在,小 x 随手写了 6 个单词,他想让你帮他找到一种填字母的方案,使得这 6 个单词都出现在了九宫格原创 2017-08-01 16:50:33 · 361 阅读 · 0 评论 -
Why Did the Cow Cross the Road III - UPCOJ 3439 - 树状数组
链接: http://exam.upc.edu.cn/problem.php?id=3439题目:题目描述The layout of Farmer John’s farm is quite peculiar, with a large circular road running around the perimeter of the main field on which his cows gra原创 2017-08-01 16:56:27 · 497 阅读 · 0 评论 -
wtaxi - UPCOJ 3641 - 贪心DP 背包
链接: http://exam.upc.edu.cn/problem.php?id=3641题目:题目描述话说小 x 有一次去参加比赛,虽然学校离比赛地点不太远,但小 x 还是想坐出租车去。大学城的出租车总是比较另类,有“拼车”一说,也就是说,你一个人坐车去,还是一堆人一起,总共需要支付的钱是一样的(每辆出租上除司机外最多坐下 4 个人)。刚好那天同校的一群 Oier 在校门口扎堆了,大家果断决定原创 2017-08-01 17:00:06 · 294 阅读 · 0 评论 -
聊斋 - UPCOJ 3560 - 枚举 暴力
链接: http://exam.upc.edu.cn/problem.php?id=3560题目:题目描述某人读完《聊斋志异》,编出这样一道题。题目为:现有男鬼(b)、女鬼(r)、小鬼(w)共n人(n<400),围站成一环(小鬼可以算是男的也可以算是女的)。从某人开始分别在两边数连续相同性别数(两边的性别可不同),直到第一次发现不同性别为止。当前数的这个人至少要同左右两边中的一方具有相同性别,并算原创 2017-08-01 17:02:29 · 650 阅读 · 0 评论 -
Cow Navigation - UPCOJ 3427 - 六维BFS
链接: http://exam.upc.edu.cn/problem.php?id=3427题目:题目描述Bessie has gotten herself stuck on the wrong side of Farmer John’s barn again, and since her vision is so poor, she needs your help navigating acro原创 2017-08-01 17:08:28 · 436 阅读 · 0 评论 -
Matrix Power Series - POJ 3233 - 矩阵快速幂
链接: http://poj.org/problem?id=3233题目:DescriptionGiven a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.InputThe input contains exactly one test case. The first line of原创 2017-08-06 15:53:28 · 357 阅读 · 2 评论 -
Kiki & Little Kiki 2 - HDU 2276 - 矩阵快速幂
链接: 题目:Problem Description There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on,原创 2017-08-06 14:57:28 · 431 阅读 · 0 评论 -
Fibonacci - POJ 3070 - 矩阵快速幂
链接: http://poj.org/problem?id=3070题目:DescriptionIn the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0,原创 2017-08-01 20:38:54 · 345 阅读 · 0 评论 -
化妆晚会 - UPCOJ 3613 - 二分查找
题目:地址:http://exam.upc.edu.cn/problem.php?id=3613题目描述 万圣节又到了!FJ打算带他的奶牛去参加化装晚会,但是,FJ只做了一套能容下两头总长不超过S (1≤S≤1000000)的奶牛恐怖服装。FJ养了N(2≤N≤20000)头按1–N顺序编号的奶牛,编号为i的奶牛的长度为L_i(1≤L_i≤1000000)。如果两头奶牛的总长度不超过S,那么她们就能原创 2017-07-24 18:50:29 · 1347 阅读 · 0 评论 -
母鸡下蛋 - UPCOJ 3636 - 尺取
题目:题目描述 鸡国中的母鸡最擅长下蛋了,MGMG 是鸡国中一只以下蛋产量高而闻名全鸡国的母鸡。 鸡国专供下蛋的 n 个鸡窝呈一字排列在鸡国的“下蛋中心”,从左到右依次编号为 1 到n。每个鸡窝都有一个最大可下蛋的量,其中第 i 个鸡窝的最大可下蛋量为 ci 。有时候由于MGMG 产量实在太大而无法在一个鸡窝中下完所有的蛋,不得不转移到隔壁的鸡窝继续下蛋,如果隔壁的鸡窝还是不能让它下完所有的蛋原创 2017-07-24 19:26:48 · 1322 阅读 · 0 评论 -
Petya and Exam - CodeForces 832B
题目:B. Petya and ExamIt’s hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help原创 2017-07-25 15:31:45 · 363 阅读 · 0 评论 -
Network - UVA 315 - 无向图求割点
链接: https://cn.vjudge.net/problem/UVA-315题目:DescriptionA Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N原创 2017-08-07 17:48:41 · 316 阅读 · 0 评论 -
Network of Schools - POJ 1236 - 强连通分量
链接: http://poj.org/problem?id=1236题目:DescriptionA number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to原创 2017-08-06 15:30:52 · 306 阅读 · 0 评论