cf 782# A.Andryusha and Socks B.The Meeting Place Cannot Be Changed C.Andryusha and Colored Balloons
看来快掉到灰名的蒟蒻涨rating也快。。。
A题模拟一下就好(一开始还sb,,
#include<bits/stdc++.h>
#define LL long long
using namespace std;
bool vis[];
int ans,tot,a[],n;
int main()
{
scanf("%d",&n);
for (int i=; i<=*n; i++)
{
int x; scanf("%d",&x);
if (!vis[x]) tot++,vis[x]=; else tot--;
ans=max(ans,tot);
}
cout<<ans;
}
B的话,比较神。。读完题一看,这不是个三分嘛。。B题怎么可能出三分。。然而还是水了个三分交上,(各种怕卡精度卡精度,然而还是可以的)
#include<bits/stdc++.h>
#define LL long long
#define eps 1e-8
using namespace std;
int n,x[],v[];
double get_dis(double pos)
{
double t=;
for (int i=; i<=n; i++)
t=max(t,fabs((double)pos-x[i])/(double)v[i]);
return t;
}
int main()
{
scanf("%d",&n);
for (int i=; i<=n; i++) scanf("%d",&x[i]);
for (int i=; i<=n; i++) scanf("%d",&v[i]);
double l=,r=1e9; int tot=;
double mid1,mid2;
while (r-l>eps)
{
mid1=(r-l)/+l,mid2=(r-l)/*+l;
if (get_dis(mid1)-get_dis(mid2)>eps) l=mid1;
else r=mid2;
if (++tot>) break;
}
printf("%.10lf",get_dis(mid1));
return ;
}
C题的话,,比较难写(其实是我太弱了),比较好想,最多就是儿子最多节点,儿子加上自己。(自己画个图就看出来了),
知道了这个就可以构造了。。
#include<bits/stdc++.h>
#define LL long long
#define N 100005
#define eps 1e-8
using namespace std;
int pos,n,col[N<<],mx;
struct edge{
int to,next;
}e[N<<];
int head[N<<],cnt;
void insert(int x, int y)
{
e[++cnt].to=y; e[cnt].next=head[x]; head[x]=cnt;
}
void dfs(int x, int fa)
{
int size=;
for (int i=head[x];i;i=e[i].next)
{
if (e[i].to==fa) continue;
size++;
dfs(e[i].to,x);
}
if (x==)
{
if (size+>mx) mx=size+,pos=x;
}
else if (size+>mx) mx=size+,pos=x;
}
void solve_paint(int x, int fa)
{
int orz=;
for (int i=head[x];i;i=e[i].next)
{
while (orz==col[x] || orz==col[fa]) orz++;
if (e[i].to==fa) continue;
col[e[i].to]=orz; orz++;
solve_paint(e[i].to,x);
}
}
int main()
{
scanf("%d",&n);
for (int i=; i<n; i++)
{
int x,y; scanf("%d%d",&x,&y);
insert(x,y);
insert(y,x);
}
dfs(,);
cout<<mx<<endl;
col[pos]=;
solve_paint(pos,);
for (int i=; i<=n; i++)
printf("%d ",col[i]);
return ;
}
D题看不懂题,随便做了一个交上过了pretext满心欢喜,结果还是最后挂掉了。。
cf 782# A.Andryusha and Socks B.The Meeting Place Cannot Be Changed C.Andryusha and Colored Balloons的更多相关文章
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) A. Andryusha and Socks
地址:http://codeforces.com/contest/782/problem/A 题目: A. Andryusha and Socks time limit per test 2 seco ...
- AC日记——Andryusha and Socks Codeforces 780a
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- CF782A Andryusha and Socks
题意: Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to ...
- Codeforces 782C. Andryusha and Colored Balloons 搜索
C. Andryusha and Colored Balloons time limit per test:2 seconds memory limit per test:256 megabytes ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) C Andryusha and Colored Balloons
地址:http://codeforces.com/contest/782/problem/C 题目: C. Andryusha and Colored Balloons time limit per ...
- code force 403C.C. Andryusha and Colored Balloons
C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes ...
- codeforces781A Andryusha and Colored Balloons
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...
- AC日记——Andryusha and Colored Balloons codeforces 780c
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #inc ...
- C. Andryusha and Colored Balloons
C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes ...
随机推荐
- Maven项目-端口被占用java.net.BindException: Address already in use: JVM_Bind <null>:8080解决方法
异常显示: 问题所在:之前启动的tomcat未停止,端口被占用. 解决方法: 养成良好的习惯,用完之后停掉服务.
- Golang gin框架学习
今天开始学习gin框架,在Github上找的示例的go-gin-example, 进度 日期 进展 疑惑 进展 1.30 下拉代码,初步了解gin的介绍.搭建 .mod文件 module原理.使用方法 ...
- Django 学习 之ORM多表操作
一.创建模型 1.模型关系整理 创建一对一的关系:OneToOne("要绑定关系的表名") 创建一对多的关系:ForeignKey("要绑定关系的表名") 创建 ...
- gcc/g++/make/cmake/makefile/cmakelists的恩恩怨怨
以前在windows下用VS写代码,不管有多少个文件夹,有多少个文件,写完以后只需要一键就什么都搞定了.但是当移步linux下时,除非你使用图形界面,并且使用Qt creater这类的IDE时,才可以 ...
- python3连接mysql--增删改查
ps:MYSQLdb只适用于python2.x python3不支持MYSQLdb,取而代之的是pymysql 运行会报:ImportError:No module named 'MYSQLdb' i ...
- ubuntu18.04下安装node
安装Node.js Ubuntu 18.04在其默认存储库中包含一个版本的Node.js,可用于在多个系统间提供一致的体验. 在撰写本文时,存储库中的版本是8.10.0. 这不会是最新的版本,但它应该 ...
- keep-alive 用法 及activated,deactivated这两个生命周期函数
keep-aliveProps: include - 字符串或正则表达式.只有名称匹配的组件会被缓存.exclude - 字符串或正则表达式.任何名称匹配的组件都不会被缓存.max - 数字.最多可以 ...
- Spring之byte[]传输
事出原因 某些原因,需要在在服务之间传输文件,想到只有通过Byte数组,或者是Stream传递,遂定下两方法,一个byte,一个inpustream,老样子,upload(@RequestParam( ...
- java#keytool#生成私钥证书库、公钥证书库
原文,向作者致敬
- PLSQL Developer配置Oralce11g连接
您的位置:首页 → 资讯教程 → 编程开发 → PLSQL Developer配置Oralce11g连接 PLSQL Developer配置Oralce11g连接 时间:2015/2/3 8:36:2 ...