NOIP模拟赛8
今天又爆零啦。。。
T1
题目描述
#define goodcatdog gcd
#define important i
#define judge j
神说 每个梦想就是一轮月亮,高高地孤寂地挂在清冷的夜空。为了让月亮不再孤独,灯神给她找了好多好多伴儿。现在天空上就有n轮月亮啦!
月亮在天上跟相邻的伙伴玩够以后,就开始想要去找其他月亮玩,灯神为了让月亮变得更聪明,下了一个规定:若两个月亮编号分别为important和judge,若important ,judge满足goodcatdog(important,judge)>β,则important,judge就可以联通。
现在来了一个垃圾神叫J乌拉,他想知道编号为x的月亮和编号为y的月亮是否联通,聪明的你能帮帮它吗????
输入描述
第一行为一个数T,表明有T组测试数据
四个个数n,β,x,y;
输出描述
若x,y联通,输出YeS,否则输出No
样例输入
1
12 2 8 9
样例输出
YeS
并查集,考场上写双向宽搜算错空间,然后炸了,哈哈哈
AC代码丢了。。
T2 [USACO12FEB]附近的牛Nearby Cows
https://www.luogu.org/problem/show?pid=3047
树形DP
dfs只需要预处理子树
然后对于每个点,一路向上至根节点
父节点扩展k=父节点子树扩展k-子节点子树扩展k-1
所以只管子树即可
#include<cstdio>
#define N 100001
using namespace std;
int n,m;
int front[N],to[N<<],nxt[N<<],tot,from[N<<];
int dp[N][],fa[N];
void add(int u,int v)
{
to[++tot]=v; nxt[tot]=front[u]; front[u]=tot;
to[++tot]=u; nxt[tot]=front[v]; front[v]=tot;
}
void dfs(int x,int f)
{
fa[x]=f;
for(int i=front[x];i;i=nxt[i])
if(to[i]!=f)
{
dfs(to[i],x);
for(int j=;j<=m;j++)
dp[x][j]+=dp[to[i]][j-];
}
}
void cal(int now)
{
int ans=dp[now][m];
int k=m-;
while(k>= && fa[now])
{
ans+=dp[fa[now]][k];
if(k) ans-=dp[now][k-];
k--;now=fa[now];
}
printf("%d\n",ans);
}
int main()
{
//freopen("young.in","r",stdin);
//freopen("young.out","w",stdout);
scanf("%d%d",&n,&m);
int u,v;
for(int i=;i<n;i++) scanf("%d%d",&u,&v),add(u,v);
for(int i=;i<=n;i++) scanf("%d",&dp[i][]);
dfs(,);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
dp[i][j]+=dp[i][j-];
for(int i=;i<=n;i++) cal(i);
}
T3 [POI2007]天然气管道Gaz
http://www.lydsy.com/JudgeOnline/problem.php?id=1108
只能往南和往东
所以在有解的前提下,怎么连都一个样
#include<cstdio>
using namespace std;
int main()
{
int n,x,y;
long long ans=;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&x,&y);
ans-=x; ans+=y;
}
for(int i=;i<=n;i++)
{
scanf("%d%d",&x,&y);
ans+=x; ans-=y;
}
printf("%lld",ans);
}
NOIP模拟赛8的更多相关文章
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...
- 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...
- 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...
- 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...
- CH Round #58 - OrzCC杯noip模拟赛day2
A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...
- CH Round #52 - Thinking Bear #1 (NOIP模拟赛)
A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...
- CH Round #49 - Streaming #4 (NOIP模拟赛Day2)
A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...
随机推荐
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...
- 软工1816 · Alpha冲刺(6/10)
团队信息 队名:爸爸饿了 组长博客:here 作业博客:here 组员情况 组员1(组长):王彬 过去两天完成了哪些任务 alpha冲刺时间延后一周,重新规划任务安排 完成食堂店铺经纬度标注,以供美食 ...
- HDU 5170 GTY's math problem 水题
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5170 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- mac python install zlib not available
用brew install 3.4.4(python)时报 zipimport.ZipImportError: can't decompress data; zlib not available 的错 ...
- sharepoint content type publishing
1. Create 1 Project Team sites (Site1) on SharePoint(可以用普通site)2. Go to http://<PCName>:8080/_ ...
- hash值
任何类都继承public int hashCode()方法,该方法返回的值是通过将该对象的内部地址转换为一个整数来实现的,hash表的主要作用就是在对对象进行散列的时候作为key输入.我们需要每个对象 ...
- CDN加速-内容分发网络
内容分发网络 (互联网技术) 编辑 CDN的全称是Content Delivery Network,即内容分发网络.其基本思路是尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输 ...
- Vue.js 上传文件(后台使用.net)
页面部分 <div id="app"> <form id="myform"> <input type="file&quo ...
- 【Python】Python的time和datetime模块
time 常用的有time.time()和time.sleep()函数. import time print(time.time()) 1499305554.3239055 上面的浮点数称为UNIX纪 ...
- hbase windows安装
下载目前最新版本 http://mirrors.hust.edu.cn/apache/hbase/stable/ 最新版本 hbase-1.2.6 1. 解压到D:\software\hbase-1. ...