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 ...
随机推荐
- 至少你要了解RSS
本文概要: 1.RSS是什么,有什么作用? 2.是不是所有的网站都有RSS功能? 3.没有RSS功能的网站如何订阅? 4.RSS是否已经过时? 5.推荐一些热门的RSS订阅地址 1.RSS是什么,有什 ...
- python 中的 *args 和 **kwargs
在阅读Python代码时,经常会看到如下函数的定义: def fun(*args, **kwargs): 很多同学可能会对此感到困惑,这个 * args和 **kwargs是什么东西.为啥会在源码中应 ...
- Python之第一次自夸
有一个好玩的代码 import win32com.client g = win32com.client.Dispatch("SAPI.SPVOICE") g.Speak(" ...
- VNC怎么和宿主机共享粘贴板
VNC怎么和宿主机共享粘贴板 假设目标主机是linux,终端主机是windows(就是在windows上使用VNC登陆linux) 在linux中执行vncconfig -nowin& 在li ...
- 吴裕雄--天生自然HADOOP操作实验学习笔记:qq好友推荐算法
实验目的 初步认识图计算的知识点 复习mapreduce的知识点,复习自定义排序分组的方法 学会设计mapreduce程序解决实际问题 实验原理 QQ好友推荐算法是所有推荐算法中思路最简单的,我们利用 ...
- CF1209C Paint the Digits
CF1209C Paint the Digits 题意:给定T组数据,每组数据第一行输入数字串长度,第二行输入数字串,用数字1和2对数字串进行涂色,被1涂色的数字子串和被2涂色的数字子串拼接成新的数字 ...
- 后台:Django项目创建
后台:Django项目创建 环境 """ 为luffy项目创建一个虚拟环境 >: mkvirtualenv luffy """ &qu ...
- JavaScript--选择器
1.选择器是jQuery的根基,在jQuery中,对事件处理,遍历DOM和Ajax操作都依赖于选择器. 2.选择的优点: --写法简洁: --完善的事件处理机制. 3.基本选择器: --基本选择器是j ...
- Django 3.0的新功能
谷歌翻译的,我修正并且添加了一些内容.凑合看吧. MariaDB的支持 Django现在正式支持MariaDB 10.1和更高版本.有关更多详细信息,请参见MariaDB注释. ASGI支持 Djan ...
- Verilog的非阻塞语句放到顺序块中,综合出来怎样的逻辑电路?
情境: FPGA里面计数器需要复位(计数值置零),与计数器状态有关的行为是状态机控制的,即状态机为CLEAR_TIMER状态时,计数器才完成清零动作. 清零有两个条件:(1)计数器值溢出(达到OVF门 ...