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 (aii). 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 5

      Sample Output

      010
      1X0
      010
      0000X
      11000
      00X00
      X0000
      00000

      Hint

      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的更多相关文章

  1. 135 - ZOJ Monthly, August 2014

    135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...

  2. ZOJ Monthly, August 2014

    A Abs Problem http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5330 找规律题,构造出解.copyright@ts ...

  3. 记次浙大月赛 134 - ZOJ Monthly, June 2014

    链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...

  4. ZOJ Monthly, June 2014 月赛BCDEFGH题题解

    比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不 ...

  5. ZOJ Monthly, November 2014

    做了一次月赛,没想到这么难,加上后来补上的题目也只有3个题.第一名也只有4个题啊啊啊啊~.其中两道还是水题.留坑慢慢补上来. 3832 Tilt Cylinder 给定如图所示有盖圆柱体,R,H,水面 ...

  6. 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 ...

  7. ZOJ Monthly, June 2014 解题报告

    A.Another Recurrence Sequence problemId=5287">B.Gears 题目大意:有n个齿轮,一開始各自为一组.之后进行m次操作,包含下面4种类型: ...

  8. Incircle and Circumcircle(二分+几何)浙大月赛zoj3806(详解版)图

    Incircle and Circumcircle Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge A triangle is o ...

  9. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

随机推荐

  1. Django(ORM常用字段)

    day68 参考:http://www.cnblogs.com/liwenzhou/p/8688919.html 1. Django ORM常用字段:             1. AutoField ...

  2. javascript window对象属性和方法

    window对象 window对象表示一个浏览器窗口或一个框架.在客户端JavaScript中,window对象是全局对象,所有的表达式 都在当前的环境中计算.也就是说,要引用当前窗口根本不需要特殊的 ...

  3. EF 通过修改模版 更改生成实体名称

    直接修改T4 模版中对应关系就可以了,我这里是去掉了表中的“_”

  4. Docker仓库(四)

    一.什么是仓库 仓库就是集中存放镜像的地方,分为公共仓库和私有仓库,一个容易混淆的概念是注册服务器,实际上注册服务器是存放仓库的具体服务器,一个注册服务器可以有多个仓库,而每个仓库下面有多个镜像 二. ...

  5. python获取动态网站上面的动态加载的数据(初级)

    我们在处理一些网站数据的时候,有时候我们需要的数据很多都是动态加载的,而不都是静态的,以下以一个实例来介绍简单的获取动态数据,首先申明本人小白,还在学习python中,这个方法还是比较笨拙的,但是对于 ...

  6. 微信应用号来了,微信小程序开发教程!

    关注,QQ群,微信应用号社区 511389428,511389428 微信应用开放的服务和组件包含如下: 视图容器:视图(View).滚动视图.Swiper 基础内容:图标.文本.进度条 表单组件:按 ...

  7. 在 ASP.NET MVC 中使用异步控制器

    线程池 一直想把项目改写成异步,但是ASP.NETMVC3下写的过于繁琐,.NET 4.5与ASP.NET MVC下代码写起来就比较简单了, MS好像也一直喜欢这样搞,每一个成熟的东西,都要演变好几个 ...

  8. 使用binlog2sql针对mysql进行数据恢复

    MySQL闪回原理与实战 DBA或开发人员,有时会误删或者误更新数据,如果是线上环境并且影响较大,就需要能快速回滚.传统恢复方法是利用备份重搭实例,再应用去除错误sql后的binlog来恢复数据.此法 ...

  9. bower 和 npm 的区别

    前端技术和工程实践真的是突飞猛进啊,想当年,我这个半业余前端吭哧吭哧做页面的时候,哪有这么多东西可以用啊,现在先进到我都完全看不懂了.本文主要讲一下同是包管理器的bower和npm的差别. 主要也是在 ...

  10. Element ui tree结合Vue使用遇到的一些问题(一)

    下图是一个后台管理系统,展示的是角色列表 当我点击编辑的时候,弹出一个模态框,如下图 功能需求:点击编辑按钮,弹出模态框,选择权限那块,默认选中当前角色拥有的权限. 问题:第一次点击编辑按钮时,不会选 ...