2017年 湘潭邀请赛(湖南)or 江苏省赛
这套题是叉姐出的,好难啊,先扫一遍好像没有会做的题了,仔细一想好像D最容易哎
Super Resolution |
||
| Accepted : 112 | Submit : 178 | |
| Time Limit : 1000 MS | Memory Limit : 65536 KB | |
Super ResolutionBobo has an n×m picture consists of black and white pixels. He loves the picture so he would like to scale it a×b times. That is, to replace each pixel with a×b block of pixels with the same color (see the example for clarity). InputThe input contains zero or more test cases and is terminated by end-of-file. For each test case, The first line contains four integers n,m,a,b. The i-th of the following n lines contains a binary string of length m which denotes the i-th row of the original picture. Character "
OutputFor each case, output n×a rows and m×b columns which denote the result. Sample Input2 2 1 1 Sample Output10 |
水题直接开搞,就是我把图像放大m*n倍,那不就是周围都是它的重复了,循环搞下。
#include<stdio.h>
int main(){
int n,m,a,b;
while(~scanf("%d%d%d%d",&n,&m,&a,&b)){
getchar();
char s[];
while(n--){
gets(s);
for(int k=;k<a;k++){
for(int i=;i<m;i++){
for(int j=;j<b;j++)
printf("%c",s[i]);
}
printf("\n");
}}} return ;}
然后我也没有会做的题了,群里讲I是脑洞题,我就直接开搞了
Strange Optimization |
||
| Accepted : 38 | Submit : 209 | |
| Time Limit : 1000 MS | Memory Limit : 65536 KB | |
Strange OptimizationBobo is facing a strange optimization problem. Given n,m, he is going to find a real number α such that f(12+α) is maximized, where f(t)=mini,j∈Z|i/n−j/m+t|. Help him! Note: It can be proved that the result is always rational. InputThe input contains zero or more test cases and is terminated by end-of-file. Each test case contains two integers n,m.
OutputFor each case, output a fraction p/q which denotes the result. Sample Input1 1 Sample Output1/2 NoteFor the first sample, α=0 maximizes the function. |
这个题我好像不会哎,这个脑洞开的,1/(m*n*2),这是我第一次猜的,错了啊,接下来我的方向就是找i/n-j/m的最小区间了,毕竟后面的数是个实数,这个答案符合最小公倍数啊,交上去wa,后来才发现是爆int,知道了又发现这个OJ是int64,求心理面积大小
#include <stdio.h>
__int64 gcd(__int64 a,__int64 b)
{
while(b != )
{
__int64 r = b;
b = a % b;
a = r;
}
return a;
}
int main()
{
__int64 m,n;
while(~scanf("%I64d%I64d",&n,&m)){
printf("1/%I64d\n",m/gcd(n,m)*n*);
}
return ;
}
Highway |
||
| Accepted : 37 | Submit : 151 | |
| Time Limit : 4000 MS | Memory Limit : 65536 KB | |
HighwayIn ICPCCamp there were n towns conveniently numbered with 1,2,…,n connected with (n−1) roads. The i-th road connecting towns ai and bi has length ci. It is guaranteed that any two cities reach each other using only roads. Bobo would like to build (n−1) highways so that any two towns reach each using only highways. Building a highway between towns x and y costs him δ(x,y) cents, where δ(x,y) is the length of the shortest path between towns x and y using roads. As Bobo is rich, he would like to find the most expensive way to build the (n−1) highways. InputThe input contains zero or more test cases and is terminated by end-of-file. For each test case: The first line contains an integer n. The i-th of the following (n−1) lines contains three integers ai, bi and ci.
OutputFor each test case, output an integer which denotes the result. Sample Input5 Sample Output19 |
这个题似曾相识,先DFS两次求最长路,树的直径,和蓝桥杯大臣的旅费差不多,然后再其他点到这两个点最长的距离得和。我是做不出来
和hdu2916差不多
都是树形dp,那个题的代码
#include <bits/stdc++.h>
using namespace std;
int len;
int head[],dp[],id[],dp2[],id2[];
//dp[i],从i往下倒叶子的最大距离
//id,最大距离对应的序号
//dp2,次大距离
//id2,次大序号
struct node {
int now,next,len;
} tree[];
void add(int x,int y,int z) { //建树
tree[len].now = y;
tree[len].len = z;
tree[len].next = head[x];
head[x] = len++;
tree[len].now = x;
tree[len].len = z;
tree[len].next = head[y];
head[y] = len++;
}
void dfs1(int root,int p) {
//从节点root往下倒叶子节点的最大距离
//p是root父节点
int i,j,k,tem;
dp[root] = ;
dp2[root] = ;
for(i = head[root]; i!=-; i = tree[i].next) {
k = tree[i].now;
if(k == p)//不能再找父节点
continue;
dfs1(k,root);
if(dp2[root]<dp[k]+tree[i].len) { //比次大的要大
dp2[root] = dp[k]+tree[i].len;
id2[root] = k;
if(dp2[root]>dp[root]) { //次大大于最大,交换其值与id
swap(dp2[root],dp[root]);
swap(id2[root],id[root]);
}
}
}
}
//len为p到root的长度
void dfs2(int root,int p) {
//从父亲节点开始更新
int i,j,k;
for(i = head[root]; i!=-; i = tree[i].next) {
k = tree[i].now;
if(k == p)
continue;
if(k == id[root]) { //最大距离的序号,对应的是dp[k],多以这里要加次大的
if(tree[i].len+dp2[root]>dp2[k]) {
dp2[k] = tree[i].len+dp2[root];
id2[k] = root;
if(dp2[k]>dp[k]) {
swap(dp2[k],dp[k]);
swap(id2[k],id[k]);
}
}
} else {
if(tree[i].len+dp[root]>dp2[k]) {
dp2[k] = tree[i].len+dp[root];
id2[k] = root;
if(dp2[k]>dp[k]) {
swap(dp2[k],dp[k]);
swap(id2[k],id[k]);
}
}
}
dfs2(k,root);
}
}
int main() {
int n,i,j,x,y;
while(~scanf("%d",&n)) {
len = ;
memset(head,-,sizeof(head));
for(i = ; i<=n; i++) {
scanf("%d%d",&x,&y);
add(i,x,y);
}
dfs1(,-);
dfs2(,-);
for(i = ; i<=n; i++)
printf("%d\n",dp[i]);
} return ;
}
2017年 湘潭邀请赛(湖南)or 江苏省赛的更多相关文章
- XTU 1264 - Partial Sum - [2017湘潭邀请赛E题(江苏省赛)]
2017江苏省赛的E题,当时在场上看错了题目没做出来,现在补一下…… 题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id ...
- XTU 1267 - Highway - [树的直径][2017湘潭邀请赛H题(江苏省赛)]
这道题可能有毒……总之一会儿能过一会儿不能过的,搞的我很心烦…… 依然是上次2017江苏省赛的题目,之前期末考试结束了之后有想补一下这道题,当时比较懵逼不知道怎么做……看了题解也不是很懂……就只好放弃 ...
- XTU 1260 - Determinant - [2017湘潭邀请赛A题(江苏省赛)][高斯消元法][快速幂和逆元]
是2017江苏省赛的第一题,当时在场上没做出来(废话,那个时候又不懂高斯消元怎么写……而且数论也学得一塌糊涂,现在回来补了) 省赛结束之后,题解pdf就出来了,一看题解,嗯……加一行再求逆矩阵从而得到 ...
- XTU 1261 - Roads - [最小割][2017湘潭邀请赛B题(江苏省赛)]
之前在网上搜了一个下午没搜到这道题的题解,然后同时又对着叉姐写的两行字题解看了一个下午: 虽然基本上已经知道了这题的思路,但愣是因为自己代码实现起来太繁复,外加不确定正确性,没敢码…… 但是一道题肝了 ...
- 2017 CCPC 湘潭邀请赛
都tm快一年了我还没补这套题……再不补怕是要留给退役后乐 Problem A 把$n * (n + 1)$的矩阵补成$(n + 1) * (n + 1)$的,然后高斯消元. Problem B 一看题 ...
- 湘潭邀请赛+蓝桥国赛总结暨ACM退役总结
湘潭邀请赛已经过去三个星期,蓝桥也在上个星期结束,今天也是时候写一下总结了,这应该也是我的退役总结了~ --------------------------------湘潭邀请赛----------- ...
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...
- 湘潭邀请赛 Hamiltonian Path
湘潭邀请赛的C题,哈密顿路径,边为有向且给定的所有边起点小于终点,怎么感觉是脑筋急转弯? 以后一定要牢记思维活跃一点,把复杂的事情尽量简单化而不是简单的事情复杂化. #include<cstdi ...
- 2017 湘潭邀请赛&JSCPC G&J
训练的时候对G想了一个假算法..也有很大可能是写错了.. 下来一看别人的G 看起来很奇妙.. 开始把所有的左括号翻成右括号,然后cost*=-1 这样在优先队列中就是最优的 然后for每一段 如果前缀 ...
随机推荐
- tar打包压缩命令
1. tar命令 用法: tar [选项...] [FILE]... GNU ‘tar’将许多文件一起保存至一个单独的磁带或磁盘归档,并能从归档中单独还原所需文件. 示例 tar -cf archiv ...
- xml文件解析和序列化
转载:http://blog.csdn.net/liuhe688/article/details/6415593 XmlPullParser parser = Xml.newPullParser(); ...
- [翻译] API测试的最佳实践 - 介绍
API测试的最佳实践 - 介绍 在上一篇“是什么让API测试很叼”一文中,我们讨论API与其他形式的软件测试的差异.部分是因为API之间的通信压根就没考虑让你能读懂,纯粹是为了方便计算机之间的交互而设 ...
- C/C++ 内存分配方式,堆区,栈区,new/delete/malloc/free
内存分配方式 内存分配方式有三种: [1] 从静态存储区域分配.内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在.例如全局变量, static 变量. [2] 在栈上创建.在执行函 ...
- lsattr
-a 将隐藏文件的属性也显示出来 -R 连同子目录的数据也一并列出来 chattr +aij 文件名
- IOS中Llabel整理
·UILable是iPhone界面最基本的控件,主要用来显示文本信息.·常用属性和方法有:1.创建CGRect rect = CGRectMake(100, 200, 50, 50);UILabel ...
- ZOJ 3627 Treasure Hunt II (贪心,模拟)
题意:有n个城市并排着,每个城市有些珠宝,有两个人站在第s个城市准备收集珠宝,两人可以各自行动,但两人之间的距离不能超过dis,而且每经过一个城市就需要消耗1天,他们仅有t天时间收集珠宝,问最多能收集 ...
- VirtualBox Network设置的NAT和Bridged Adapter模式区别
区别: NAT模式下,虚拟机仍然可以访问网络,但是从网络接收者的眼中看来,这些网络请求都来自宿主机,而感知不到虚拟机.外网也无法访问虚拟机网络.虚拟机和宿主机器的IP地址在不同的子网,比如192.16 ...
- Ubuntu14.04 32位安装Youcompleteme
前一段时间在ubuntu16.04 64位上安装了vim插件Youcompleteme,花了两三天才弄好.今天在ubuntu14.04 32位上安装同样的插件,才知道之前所做的安装原来是多么的简单.今 ...
- UVA1660 Cable TV Network (无向图的点连通度)
题意:求一个无向图的点连通度. 把一个点拆成一个入点和一个出点,之间连一条容量为1的有向边,表示能被用一次.最大流求最小割即可. 一些细节的东西:1.源点固定,汇点要枚举一遍,因为最小割割断以后会形成 ...