![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
UVa
文章平均质量分 62
hyqsblog
这个作者很懒,什么都没留下…
展开
-
UVa1428 - Ping pong
我有话说:这道题可以算是树状数组入门经典。要求在两个点之间找一个点,且这个点的值在两个点之间,求有这样的三点集合共有多少个。 这道题我们可以先后找一个点,假设a1到ai-1中有ci个小于ai,ai+1到an中有di个小于ai。那么以该店为中间点则共有ci(n-i-di)+di(i-1-ci)种点集。则转换为求ci和di。 我们这样计算ci,从左到右扫描ai令xi表示目前为止已考虑过的ai中是否存原创 2015-12-13 16:44:23 · 569 阅读 · 0 评论 -
1151 - Buy or Build
World Wide Networks (WWN) is a leading company that operates large telecommunication networks. WWN would like to setup a new network in Borduria, a nice country that recently managed to get rid of its原创 2015-07-22 19:26:10 · 360 阅读 · 0 评论 -
1515 - Pool construction
我有话说: 在这道题里,首先我们根据题目可以想到的是要预先算出把边界的洞填上草所需要的花费,同时在图中修改。然后就是要考虑内部的情况。所有的点都是草或者洞,栅栏是把草和洞隔开的作用,就对应上图论中“割”的概念。我们可以把所有的草连上同一个源点s,所有的洞连上同一个汇点t。从s到草的边我们记其容量为d的边,即对应只有把这条边切断,这个点才会属于“洞”这一集合,即和t相连。然后根据在图中原创 2015-08-17 13:16:39 · 453 阅读 · 0 评论 -
UVA12174
我有话说: 这道题运用了滑动窗口这一技巧。转载了刘汝佳大神的代码。做了一下翻译。#include<iostream>#include<vector>using namespace std;const int maxn = 100000 + 5;int s, n, x[maxn*3], cnt[maxn], ok[maxn*2];int main() { int T; c原创 2015-07-22 11:27:26 · 605 阅读 · 3 评论 -
818 - Cutting Chains
Cutting Chains What a find! Anna Locke has just bought several links of chain some of which may be connected. They are made from zorkium, a material that was frequently used to manufacture jewelry in原创 2015-07-21 09:21:43 · 440 阅读 · 0 评论 -
11882 - Biggest Number
题目大意: 给出nXm的矩阵方格。其中有一些是数字,有一些是#即障碍。 可以从任何一个数字个开始,取走格中的数字。不能走到障碍上,也不能经过同一个数字格两次。问所能得到的最大数字。 我有话说: 很明显是搜索。但是裸搜是肯定超时的。所以这道题可以说是剪枝的试验田。在写之前,我参看了网上大神们的各种强剪枝。最后写了一下代码。但因为自己两个小错误看了一原创 2015-07-21 13:17:52 · 652 阅读 · 0 评论 -
10384 - The Wall Pushers
我有话说: 用了迭代加深搜索。主要就考虑两类。没有墙和有墙但是能推的两种情况。分别进行枚举。比较麻烦的不是程序过程,而是由于题目中x y坐标的设定,以及推墙后的运算,要有清晰的思路。#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;co原创 2015-07-20 16:17:28 · 458 阅读 · 0 评论 -
690 - Pipeline Scheduling
Pipeline Scheduling An arithmetic pipeline is designed to process more than one task simultaneously in an overlap- ping manner. It includes function units and data paths among them. Tasks are process原创 2015-07-20 20:18:39 · 566 阅读 · 0 评论 -
UVa12107 - Digit Puzzle
题目大意是给你三个待定的字符串。形如7 * 8 。要求变换空格或者数字似的前一个字符串X后一个字符串=最后一个字符串有唯一解,且变换次数最少,多解时输出字典序最小的答案。规定空格的字典序小于数字。星号指代空格。 我有话说: 大致思想就是对每一位上的数字爆搜枚举,枚举完后并检验。这就要用到两个dfs。一个枚举数,一个检验。但在结构上都差不多。#include <iost原创 2015-07-21 07:47:05 · 1428 阅读 · 0 评论 -
1343 - The Rotation Game
The rotation game uses a # shaped board, which can hold 24 pieces of square blocks (see Fig.1). The blocks are marked with symbols 1, 2 and 3, with exactly 8 pieces of each kind. Initially, the blocks原创 2015-07-19 13:00:12 · 266 阅读 · 0 评论 -
12569 - Planning mobile robot on Tree (EASY Version)
我有话说: 这是一道bfs。因为他要移动每一个石头或者机器人。换成dfs的话,一个是不知道目标状态(最小步数),二是容易爆栈。既然是bfs,那么要考虑一下如何判重,想法是转换成二进制,对于编号上的格子是否有石头或者机器人采用1或0表示。但是,数组开太小会RE太大会TLE,后来看了一个大神的题解,选择了一个恰好的maxstate。#include <iostream>#includ原创 2015-07-20 10:02:23 · 394 阅读 · 0 评论 -
1380 - A Scheduling Problem
There is a set of jobs, say x1, x2,…, xn , to be scheduled. Each job needs one day to complete. Your task is to schedule the jobs so that they can be nished in a minimum number of days. There are two原创 2015-07-20 08:33:55 · 456 阅读 · 0 评论 -
11214 - Guarding the Chessboard
Problem GGuarding the ChessboardGiven an n*m chessboard with some marked squares, your task is to place as few queens as possible to guard (attack or occupy) all marked squares. Below is a solution to原创 2015-07-19 19:52:21 · 424 阅读 · 0 评论 -
12325 - Zombie's Treasure Chest
我有话说:开始是想写背包的,但是碍于数据范围,想到了枚举。 枚举物体1的个数,尽量装物体2,这个方法在V/S1较小是可行的。如果S1很小,那么就枚举物体2,但是当S2也很小的时候该怎么办? 注意到S2个物体1和S1个物体2所占的空间相同。但总价值有三种情况: 1.S2*V1>S1*V2;那么物体2最多只能装S1-1个。否则就可以转换成S2个物体一这是更优解。 2.S2*V1< S1*V2 类原创 2015-07-19 09:28:46 · 397 阅读 · 0 评论 -
UVa1658 Admiral
#include #include #include #include #include #include #include using namespace std;const int maxn=2000+10;const int INF=1000000000;struct Edge{ int from,to,cap,flow,cost; Edge(int u,int原创 2015-08-18 13:14:50 · 294 阅读 · 0 评论 -
UVA10118 - Free Candies
我有话说: 这道题比较简单,总思路就是dfs+记忆化搜索#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <vector>#include <queue>using namespace std;const int maxn=100;int n;int c原创 2015-09-01 13:00:18 · 453 阅读 · 0 评论 -
UVa1006 - Fixed Partition Memory Management
A technique used in early multiprogramming operating systems involved partitioning the available primary memory into a number of regions with each region having a fixed size, different regions potenti原创 2015-10-30 14:18:32 · 515 阅读 · 0 评论 -
UVa1411-Ants
我有话说: 这道题是KM算法的一个非常巧妙的应用。对图上的的黑点和白点(数量相等)进行二分图最佳完美匹配,最后得到的最大权值即答案。为什么呢? 我们看假设图中a1-b1和a2-b2相交,那么dist(a1,b1)+dist(a2,b2)>dist(a1,b2)+dist(a2,b1); 所以我们求所有点对之间的距离最小值就可以了。最小值?不是说要求最大原创 2015-10-29 19:34:22 · 444 阅读 · 0 评论 -
753 - A Plug for UNIX
A Plug for UNIXYou are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to make the free flow of info原创 2015-10-29 10:56:58 · 295 阅读 · 0 评论 -
UVa307Sticks
George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had origi原创 2015-10-28 08:51:53 · 367 阅读 · 0 评论 -
UVa11478 - Halum
#include<iostream>#include<string>#include<cstring>#include<sstream>#include<vector>#include<algorithm>#include<queue>#include<cstdio>using namespace std;const int maxn=3000+10;const int INF=原创 2015-10-27 16:09:09 · 290 阅读 · 0 评论 -
1604 - Cubic Eight-Puzzle
我有话说: 这道题叫做立体八数码问题。但绝对比八数码问题要难得多。一个是状态数量增加,另外一个是状态的难以表示。这道题的基本思路是双向广搜+深搜;并且对广搜的步数有一个上限,正向21,反向9,是试验过最快的一种。#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include原创 2015-10-20 20:27:13 · 567 阅读 · 0 评论 -
UVA11235 - Frequent values
我有话说: 这道题可以看作RMQ问题的入门。RMQ问题就是区间范围最小值问题。 下面给出模版算法:struct RMQ{ int d[maxn][maxlog]; void init(const vector<int>& A) { int n=A.size(); for(int i=0;i<n;i++)d[i][0]=A[i];原创 2015-10-18 20:19:58 · 296 阅读 · 0 评论 -
1232 - SKYLINE
The skyline of Singapore as viewed from the Marina Promenade (shown on the left) is one of the iconic scenes of Singapore. Country X would also like to create an iconic skyline, and it has put up a cal原创 2015-11-03 14:36:42 · 418 阅读 · 0 评论 -
12299 - RMQ with Shifts
In the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R) (L ≤ R), we report the minimum value among A[L], A[L + 1], … , A[R]. Note that the indices s原创 2015-11-03 13:22:42 · 300 阅读 · 0 评论 -
UVa816 Abbott's Revenge
// UVa816 Abbott's Revenge// Rujia Liu#include<cstdio>#include<cstring>#include<vector>#include<queue>using namespace std;struct Node { int r, c, dir; // 站在(r,c),面朝方向dir(0~3分别表示N, E, S, W) No原创 2015-10-16 20:17:10 · 570 阅读 · 0 评论 -
UVA1631 - Locker
#include #include #include #include #include #include using namespace std;const int maxn=1000+10;const int INF=100000000;char s1[maxn],s2[maxn];int cost[maxn][maxn],dp[2][maxn];void Init()原创 2015-09-15 13:18:12 · 465 阅读 · 0 评论 -
UVA1630 - Folding
#include #include #include #include #include #include using namespace std;const int maxn=100+10;const int INF=1000000;int dp[maxn][maxn];string flod[maxn][maxn];string str;int judge(int L原创 2015-09-08 12:59:02 · 425 阅读 · 0 评论 -
1629 - Cake slicing
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=848&problem=4504&mosmsg=Submission+received+with+ID+16048725 我有话说: 这道题的大致思想是动态规划中的记忆化搜索。求对于给定区域原创 2015-09-05 17:06:01 · 287 阅读 · 0 评论 -
1252 - Twenty Questions
Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with yes" orno”. Using those features, we can identify any object from the原创 2015-07-17 16:54:54 · 301 阅读 · 0 评论 -
12099 - The Bookcase
No wonder the old bookcase caved under the massive piles of books Tom had stacked on it. He had better build a new one, this time large enough to hold all of his books. Tom nds it practical to hav原创 2015-07-17 14:40:50 · 573 阅读 · 0 评论 -
11212 - Editing a Book
Problem EEditing a BookYou have n equal-length paragraphs numbered 1 to n. Now you want to arrange them in the order of 1, 2, …, n. With the help of a clipboard, you can easily do this: Ctrl-X (cut) an原创 2015-06-28 17:25:12 · 456 阅读 · 0 评论 -
1601 - The Morning after Halloween
You are working for an amusement park as an operator of an obakeyashiki, or a haunted house, in which guests walk through narrow and dark corridors. The house is proud of their lively ghosts, which are原创 2015-06-24 13:30:59 · 525 阅读 · 1 评论 -
1347 - Tour
John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts visiting beautiful places. To save money, John must determine the shortest closed tour that connects hi原创 2015-06-23 13:23:25 · 285 阅读 · 0 评论 -
10618 - Tango Tango Insurrection
Problem A: Tango Tango Insurrection You are attempting to learn to play a simple arcade dancing game. The game has 4 arrows set into a pad: Up, Left, Down, Right. While a song plays, you watch arrows原创 2015-06-01 13:29:17 · 386 阅读 · 0 评论 -
UVA10559 Blocks
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn=200+10;int n,A[maxn],d[maxn][maxn][maxn];int dp(int i,int j,int k)//表示对区间[i,j]后面还跟了k个和A原创 2015-05-31 15:30:57 · 769 阅读 · 0 评论 -
1627 - Team them up!
Your task is to divide a number of persons into two teams, in such a way, that:everyone belongs to one of the teams; every team has at least one member; every person in the team knows every other per原创 2015-06-11 13:21:50 · 374 阅读 · 0 评论 -
12563 - Jin Ge Jin Qu hao
(If you smiled when you see the title, this problem is for you ^_^) For those who don’t know KTV, see: http://en.wikipedia.org/wiki/Karaoke_box There is one very popular song called Jin Ge Jin Qu(劲歌金原创 2015-06-18 13:09:34 · 398 阅读 · 0 评论 -
UVa1625 - Color Length
Cars painted in different colors are moving in a row on the road as shown in Figure 1. The color of each car is represented by a single character and the distance of two adjacent cars is assumed to be原创 2015-05-28 12:48:32 · 352 阅读 · 0 评论 -
1626 - Brackets sequence
Let us define a regular brackets sequence in the following way:Empty sequence is a regular sequence. If S is a regular sequence, then (S) and [S] are both regular sequences. If A and B are regular se原创 2015-05-17 16:20:29 · 253 阅读 · 0 评论