浙大月赛ZOJ Monthly, August 2014
Abs Problem
Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge
Alice and Bob is playing a game, and this time the game is all about the absolute value!
Alice has N different positive integers, and each number is not greater than N. Bob has a lot of blank paper, and he is responsible for the calculation things. The rule of game is pretty simple. First, Alice chooses a number a1 from the N integers, and Bob will write it down on the first paper, that's b1. Then in the following kth rounds, Alice will choose a number ak (2 ≤ k ≤ N), then Bob will write the number bk=|ak-bk-1| on the kth paper. |x| means the absolute value of x.
Now Alice and Bob want to kown, what is the maximum and minimum value of bN. And you should tell them how to achieve that!
Input
The input consists of multiple test cases;
For each test case, the first line consists one integer N, the number of integers Alice have. (1 ≤ N ≤ 50000)
Output
For each test case, firstly print one line containing two numbers, the first one is the minimum value, and the second is the maximum value.
Then print one line containing N numbers, the order of integers that Alice should choose to achieve the minimum value. Then print one line containing N numbers, the order of integers that Alice should choose to achieve the maximum value.
Attention: Alice won't choose a integer more than twice.
Sample Input
2
Sample Output
1 1
1 2
2 1 题意:找出序列使b[n]最小和最大;
很容易发现最小值不是1就是0,最大值不是n就是n - 1;
又由于这是特殊判断题,So。。。
#include<stdio.h>
#include<math.h>
int main()
{
int N,i,j,max,min;
while(scanf("%d",&N)!=EOF)
{
min=N%;
max=(N-)%;
if(min==||min==)
min=;
else min=;
if(max==||max==)
max=;
else max=;
printf("%d %d\n",min,N-max); printf("%d",N);
for(i=N-; i>; i--)
printf(" %d",i);
printf("\n"); printf("%d",N-);
for(i=N-; i>; i--)
printf(" %d",i);
printf(" %d\n",N);
}
return ;
}
比赛的时候一直纠结与绝对值,没好好思考。。。真是太失败了!
加油!!!
Machine
Time Limit: 2 Seconds Memory Limit: 65536 KB
In a typical assembly line, machines are connected one by one. The first machine's output product will be the second machine's raw material. To simplify the problem, we put all machines into a two-dimension shelf. Every machine occupied exactly one grid and has two input ports and only one output port. One input port can get material from only one machine.

Pipes will be used to connect between these machines. There are two kinds of pipes : 'I' kind and 'L' kind. We should notice that the 'I' kind pipe can be linked one by one. Each pipe will also occupied one grid.
In Bob's factory, each machine will get raw materials from zero, one or two other machines. Some machines don't need any input materials, but any machine must have an output. Machines are coded by numbers from 1 to n. The output of the machines with greater code can be the input of the machines with less code. The machine NO.1's output product will be the final product, and will not be any other machine's input. Bob's factory has a shelf with infinite height, but finite width. He will give you the dependency relationship of these machines, and want you to arrange these machines and pipes so that he can minimize the width of the shelf.
Here's an example for you to help understand :

Products will falling from higher machine to lower machine through the pipes. Here, machine 1 gets materials from machine 2 and machine 3. The whole width of this system is 2.
Input
For each case, the first line will be an integer n indicates the number of the machines (2≤ n≤ 10000). The following line will include n-1 numbers. The i-th number ai means that the output of machine i+1 will be the input of machine ai (ai≤ i). The same code will be appeared at most twice. Notice machine 1's output will be the final output, and won't be any machine's input.
Output
For each case, we need exactly one integer as output, which is the minimal width of the shelf.
Sample Input
3
1 1
7
1 1 2 2 3 3
Sample Output
2
3
Hint
Case 1 is the example.
Case 2:

This problem contains massive input and output, please use efficient IO
methods.
题意:就是说有2种管子,管子的高度可以无限长,但宽度一致,问最小的宽度;输入第i个数表示第i+1个容器将要输向哪个容器;
思路:其实就是dfs,每次dfs下去,把子树宽度保存下来,然后找最大值,如果有多个,就是最大值+cnt宽度;
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector<int>map[];
int dp[];
void dfs(int p)
{
int i,j,flag,len;
len=map[p].size();
dp[p]=;
for(i=;i<len;i++)
{
j=map[p][i];
dfs(j);
if(dp[p]<dp[j])flag=dp[j];//取大流
else if(dp[p]==dp[j])flag=dp[p]+;
dp[p]=flag;
}
if(dp[p]==)dp[p]=;
}
int main()
{
int n,a;
while(scanf("%d",&n)>)
{
for(int i=;i<=n;i++)map[i].clear();
for(int i=;i<=n;i++)
{
scanf("%d",&a);
map[a].push_back(i);
}
dfs();
printf("%d\n",dp[]);
}
}
比赛的时候也没做出来,总是WA原因是找分支的时候应该取大的;
加油!!!
YY's Minions
Time Limit: 2 Seconds Memory Limit: 65536 KB
Despite YY's so much homework, she would like to take some time to play with her minions first.
YY lines her minions up to an N*M matrix. Every minion has two statuses: awake or asleep. We use 0(the digit) to represent that it is asleep, and 1 for awake. Also, we define the minions who are around a minion closest in one of the eight directions its neighbors. And every minute every minion will change its status by the following specific rules:
- If this minion is awake, and the number of its neighbors who are awake is less than 2, this minion will feel lonely and turn to asleep.
- If this minion is awake, and the number of its neighbors who are awake is more than 3, this minion will turn to asleep for it will feel too crowded.
- If this minion is awake, and the number of its neighbors who are awake is exactly 2 or 3, this minion will keep being awake and feel very happy.
- If this minion is asleep, and the number of its neighbors who are awake is exactly 3, this minion will wake up because of the noise. Note that all changes take place at the same time at the beginning of a specific minute.
Also, some minions will get bored and leave this silly game. We use 'X's to describe them. We suppose that a minion would leave after T minutes. It will leave at the end of the Tth minute. Its status is considered during the change at the beginning of the Tth minute, and should be ignored after that. Of course, one minion will not leave twice!
YY is a girl full of curiosity and wants to know every minion's status after F minutes. But you know she is weak and lazy! Please help this cute girl to solve this problem :)
Input
There are multiple test cases.
The first line contains the number of test cases Q. 1<=Q<=100.
For each case, there are several lines:
The
first line contains four integers N, M, F,
K. K means the number of leaving messages.
1<=N, M<=50, 1<=F<=1000,
1<=K<=N*M.
Next N lines are the matrix which
shows the initial status of each minion. Each line contains M chars.
We guarantee that 'X' wouldn't appear in initial status matrix.
And next
K lines are the leaving messages. Each line contains three integers
Ti, Xi, Yi,
They mean the minion who is located in (Xi,
Yi) will leave the game at the end of the
Tith minutes.
1<=Ti<= F,
1<=Xi<=N,
1<=Yi<=M.Output
For each case, output N lines as a matrix which shows the status
of each minion after F minutes.Sample Input
2
3 3 2 1
101
110
001
1 2 2
5 5 6 3
10111
01000
00000
01100
10000
2 3 3
2 4 1
5 1 5Sample Output
010
1X0
010
0000X
11000
00X00
X0000
00000Hint
For case 1:
T=0, the game starts
101
110
001
---------------
at the beginning of T=1, a change took place
100
101
010
---------------
at the end of T=1 (the minion in (2,2) left)
100
1X1
010
---------------
at the beginning of T=2, a change took place
010
1X0
010
---------------
at the end of T=2 (nothing changed for no minion left at T=2)
010
1X0
010
Author: XIAO, Zimu
Source: ZOJ Monthly, August
2014
模拟题;按照说的做就好了。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
char str[][];
int a[][],aa[][];
int t[],x[],y[];
int d[][]= {{,},{,},{,-},{,},{,-},{-,},{-,},{-,-}};
int main()
{
int q,n,m,f,k,r,e;
int i,j,cnt,c;
scanf("%d",&q);
while(q--)
{
memset(a,,sizeof(a));
memset(t,,sizeof(t));
memset(x,,sizeof(x));
memset(y,,sizeof(y));
memset(str,,sizeof(str));
scanf("%d%d%d%d",&n,&m,&f,&k);
getchar();
for(i=; i<n; i++)
{
for(j=; j<m; j++)
scanf("%c",&str[i][j]);
getchar();
} for(i=; i<n; i++)
{
for(j=; j<m; j++)
{
if(str[i][j]=='')
a[i][j]=;
if(str[i][j]=='')
a[i][j]=;
}
} for(i=; i<k; i++)
scanf("%d%d%d",&t[i],&x[i],&y[i]);
for(r=; r<=f; r++)
{
memset(aa,,sizeof(aa));
for(i=; i<n; i++)
{
for(j=; j<m; j++)
{
if(a[i][j]==)
{
for(e=;e<;e++)
{
int xx=i+d[e][];
int yy=j+d[e][];
if(xx>=&&yy>=&&xx<n&&yy<m&&a[xx][yy]!=)
aa[xx][yy]++;
}
}
}
}
for(i=; i<n; i++)
{
for(j=; j<m; j++)
{
if(a[i][j]==)
continue;
if(a[i][j]==)
{
if(aa[i][j]<||aa[i][j]>)
a[i][j]=;
}
else if(a[i][j]==)
{
if(aa[i][j]==)
a[i][j]=;
}
}
}
for(i=;i<k;i++)
{
if(r==t[i])
a[x[i]-][y[i]-]=;
}
}
for(i=; i<n; i++)
{
for(j=; j<m; j++)
{
if(a[i][j]==)
printf("X");
else
printf("%d",a[i][j]);
}
printf("\n");
}
}
return ;
}
比赛的时候都木有看题目 /
哭
加油!!!
Incircle and Circumcircle
Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge
A triangle is one the basic shapes in geometry. It's a polygon with three vertices and three sides which are line segments. A triangle with vertices A, B, C is denoted ΔABC. And its three sides, BC, CA, AB are often denoted a, b and c.
The incircle of a triangle is the largest circle contained in the triangle, it is tangent to the three sides. The center of the incircle is called the triangle's incenter and the radius of the incircle is called inradius, which is denoted r.
The circumcircle of a triangle is the circle which passes through all its three vertices. The center of the this circle is called circumcenter and its radius is called circumradius, which is denoted R.
It's very easy to calculate r and R after knowing a, b and c. Now you are given r and R, can you calculate a valid triple (a, b, c)?
Input
There are multiple cases. Each case has two positive integers r and R in one line. (r and R are less than 105)
Ouput
For each case, print three floating numbers a, b and c in one line if it's possible to get r and R. If there are no possible tuples, print "NO Solution!".
The judge program uses your a, b and c to calculate the inradius and circumradius. Only the relative error of your inradius and circumradius less than 10-8 will be accepted.
Sample Input
1 2
2 5
9 9
Sample Ouput
3.464101615137754587 3.464101615137754587 3.464101615137754587
6 8 10
NO Solution! 解题详见:寻找&星空の孩子比赛的时候没想到不知道怎么二分了。。。。。/悲剧! 加油!!!
浙大月赛ZOJ Monthly, August 2014的更多相关文章
- 135 - ZOJ Monthly, August 2014
135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...
- ZOJ Monthly, August 2014
A Abs Problem http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5330 找规律题,构造出解.copyright@ts ...
- 记次浙大月赛 134 - ZOJ Monthly, June 2014
链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...
- ZOJ Monthly, June 2014 月赛BCDEFGH题题解
比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不 ...
- ZOJ Monthly, November 2014
做了一次月赛,没想到这么难,加上后来补上的题目也只有3个题.第一名也只有4个题啊啊啊啊~.其中两道还是水题.留坑慢慢补上来. 3832 Tilt Cylinder 给定如图所示有盖圆柱体,R,H,水面 ...
- 137 - ZOJ Monthly, November 2014 - J Poker Face
Poker Face Time Limit: 2 Seconds Memory Limit: 65536 KB As is known to all, coders are lack of ...
- ZOJ Monthly, June 2014 解题报告
A.Another Recurrence Sequence problemId=5287">B.Gears 题目大意:有n个齿轮,一開始各自为一组.之后进行m次操作,包含下面4种类型: ...
- Incircle and Circumcircle(二分+几何)浙大月赛zoj3806(详解版)图
Incircle and Circumcircle Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge A triangle is o ...
- ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)
题目链接 ZOJ Monthly, March 2018 Problem G 题意 给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...
随机推荐
- 【转】Windows IIS注册asp 此操作系统版本不支持此选项 错误解决方法
原文:https://blog.csdn.net/sweety820/article/details/79538973 更新Win10,原来的IIS站点访问不了,原因是因为IIS 没有.net 4.5 ...
- CentOS 7 - 创建新用户
当进行服务器操作时,我们尽量不要使用root用户进行操作,特别是当我们使用生产环境时. 本文我们将介绍CentOS 7下用户的创建. 创建新用户 adduser 用户名 更改用户密码 passwd 用 ...
- CDH中如何升级Spark
公司平时使用的CDH版本的hadoop生态,spark任务是基于yarn来管理的,而不是基于原生的spark master slave集群管理. 因此任务的大致启动模式是: 如果是Cluster模式: ...
- Spring Boot中使用JdbcTemplate访问数据库
本文介绍在Spring Boot基础下配置数据源和通过JdbcTemplate编写数据访问的示例. 数据源配置 在我们访问数据库的时候,需要先配置一个数据源,下面分别介绍一下几种不同的数据库配置方式. ...
- D3.js的基础部分之数组的处理 数组的排序和求值(v3版本)
操作数组 D3提供了将数组洗牌.合并等操作,使用起来是很方便的. d3.shuffle(array,[,lo[,ji]]) : //随机排列数组. d3.merge(arrays) : / ...
- FastDFD安装遇到的问题
如果按照步骤安装最后却发现 sudo service fdfs_trackerd start 启动不了,那么重启一下虚拟机就可以了
- python粘包分析与解决
TCP与UDP协议 TCP(transport control protocol,传输控制协议)是面向连接的,面向流的,提供高可靠性服务.收发两端(客户端和服务器端)都要有一一成对的socket,因此 ...
- vue10行代码实现上拉翻页加载更多数据,纯手写js实现下拉刷新上拉翻页不引用任何第三方插件
vue10行代码实现上拉翻页加载更多数据,纯手写js实现下拉刷新上拉翻页不引用任何第三方插件/库 一提到移动端的下拉刷新上拉翻页,你可能就会想到iScroll插件,没错iScroll是一个高性能,资源 ...
- 课程一(Neural Networks and Deep Learning),第二周(Basics of Neural Network programming)—— 4、Logistic Regression with a Neural Network mindset
Logistic Regression with a Neural Network mindset Welcome to the first (required) programming exerci ...
- WebStorm project 打开多个项目的方法
File ---> Setting ---> Project:xxx ---> Sirectories 点击右侧 + Add content root,选择目录后即可显示该项目. ...