
OJ系列-UVa
文章平均质量分 69
sortmin
这个作者很懒,什么都没留下…
展开
-
UVa-1585 - Score
题解:循环统计连续的O将对应的分数加上即可。 AC代码:#include#includeusing namespace std;const int maxn = 87;#define _for(i,a,b) for(int i=a;i<=b;i++)char s[maxn];int ans,n;int main(){ scanf("%d",&n);原创 2018-02-04 01:26:31 · 244 阅读 · 0 评论 -
UVa-1347 -Tour(DP)
题意:给定二维平面上的n个坐标,然后找到一条线路,从最左边的点出发,然后到最右边的点,然后再返回,只有起点和终点的点可以经过两次。找一条最短路。题解:走过去再走回来不经过相同的点可以转换为两个人分别走两条路去到达终点,用dp[i][j]表示两人最远的走到max(i,j)的情况,那么下一个决策就是看谁去走下一个点,即d[i][j]=min(dp[i+1][j]+dist[i][j],dp[i+1][...原创 2018-07-16 14:29:22 · 197 阅读 · 0 评论 -
UVAlive 6959 Judging hash
JudgingTime Limit: 20 Sec Memory Limit: 256 MB题目连接http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=114147DescriptionThe NWERC organisers have decided that they want to improve the automati...原创 2018-06-26 02:07:35 · 250 阅读 · 0 评论 -
UVA 1605 - Building for UN
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4480题意:有N个国家,设计一座大楼使每个国家都与其他国家相邻,相邻包括上下左右。题解:N最大50,采取两层,第一层每行相同,第二层每列相同,这样最后就能满足都相邻的条件。...原创 2018-06-11 14:34:51 · 226 阅读 · 0 评论 -
UVA10048 - Audiophobia
UVA10048 - Audiophobia题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=989题意:给定N个点M条边,给定q个询问,询问x-y的路径上使得经过的每条边...原创 2018-05-20 00:00:52 · 243 阅读 · 0 评论 -
UVA247 - Calling Circles
UVA247 - Calling Circles题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=183题意:n个人互相打电话,则说明他们在一个电话圈,即环内,给定n个人和m次通话,将...原创 2018-05-19 23:26:15 · 246 阅读 · 0 评论 -
Slim Span UVA - 1395(并查集)
Slim Span UVA - 1395 题目链接:https://vjudge.net/problem/UVA-1395 题意:给定n个节点的图,求一个生成树使得生成树的最大边-最小边的差最小。 题解:按权值排序后遍历L-R的点看是否满足生成树的条件,满...原创 2018-05-19 00:53:51 · 234 阅读 · 0 评论 -
LA - 3644 - X-Plosives
LA3644 - X-Plosives题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1645题意:有N种简单化...原创 2018-05-13 04:12:18 · 255 阅读 · 0 评论 -
UVa - 712 - S-Trees
712 - S-Trees题解:统计每一层节点,每遇到1就增加当前区间的一半路程即可。AC代码:#include#include#include#include#includeusing namespace std;#define _for(i,a,b) for(int i=(a);i<=(b);i++)const int maxn = 130;int n,原创 2018-02-06 23:32:41 · 234 阅读 · 0 评论 -
UVa - 673 - Parentheses Balance
673 Parentheses Balance 题解:栈的基本使用,左括号入栈,右括号就判断是不是和栈首匹配,注意空串和每次栈的清空。 AC代码:#include#include#include#includeusing namespace std;stack S;int t;char s[260];bool check(char a,char b){原创 2018-02-05 01:26:22 · 197 阅读 · 0 评论 -
UVa - 455 - Periodic Strings
455 - Periodic Strings题解:字符串周期满足1-length的长度范围,所以暴力模拟即可,这道题输入每次中间会有空行,需要puts,而输出并不需要特殊处理末尾空行也能A。AC代码:#include#includeusing namespace std;char s[85];int t;bool check(int k,int n){ int原创 2018-02-04 19:07:02 · 193 阅读 · 0 评论 -
UVa - 1225 - Digit Counting
UVa - 1225 - Digit Counting题解:因为N的值很小,直接统计每个数的各位数记录在数组即可。AC代码:#includeusing namespace std;const int maxn = 10007;int a[maxn][10];int t,n;int main(){ scanf("%d",&t); for(int i=1;i<=原创 2018-02-04 16:30:58 · 241 阅读 · 0 评论 -
UVa - 1586 - Molar mass
题解:模拟即可,统计每个原子的个数,可能会有两位数的情况,需要进行特殊处理。 AC代码:#include#includeusing namespace std;const int maxn = 87;char s[maxn];int n;bool check(char a){ if(a=='C'||a=='N'||a=='O'||a=='H')return true;原创 2018-02-04 01:45:06 · 210 阅读 · 0 评论 -
The Tower of Babylon (UVA-437)
题目链接:https://vjudge.net/problem/UVA-437题意:给定N种立方体,每种无限个,可以任意旋转,问最高能立起来多少个,即上一个的长宽均小于下面的长宽。题解:每种旋转一共有6种情况,然后按排序从最大的往下找即可。AC代码:#include <iostream>#include <algorithm>#include <string>...原创 2018-07-16 01:10:19 · 232 阅读 · 0 评论