济南day1下午
下午
预:60+100+30
实:30+30+30
T1水题(water)
T1写了二分图匹配
听说有70分,写挫了....
正解:贪心,按长度排序,
对于第一幅牌里面的,在第二个里面,找一个长度小于,高度最接近的牌
进行覆盖。
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
int n;
multiset <int> s;
struct node {int x,y;} a[],b[];
int cmp(node i,node j) {return i.x<j.x;}
int main()
{
freopen("water.in","r",stdin);
freopen("water.out","w",stdout);
int T;
T=;
while(T--)
{
scanf("%d",&n);
for(int i=;i<n;i++) scanf("%d%d",&a[i].x,&a[i].y);
for(int i=;i<n;i++) scanf("%d%d",&b[i].x,&b[i].y);
sort(a,a+n,cmp);
sort(b,b+n,cmp);
s.clear();
int k=,ans=;
for(int i=;i<n;i++)
{
while(a[i].x>=b[k].x&&k<n)
{
s.insert(b[k].y);
k++;
}
if(s.empty())continue;
multiset<int>::iterator it=s.upper_bound(a[i].y);
if (it==s.begin()) continue; it--;
ans++; s.erase(it);
}
printf("%d\n",ans);
}
return ;
}
T2下午梦境(dream)
手推公式,推错了.....30
正解dp||爆搜
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int n,sum,ans,dp[][],DP[][],i,j,k,l;
int main()
{
freopen("dream.in","r",stdin);
freopen("dream.out","w",stdout);
scanf("%d",&n);
sum=int(log(n)/log()+0.000000001)+;
dp[][]=;
for (i=; i<sum; i++)
{
for (j=; j<=n; j++)
for (k=; k<=n; k++)
if (dp[j][k])
for (l=k+; l<=j+; l++)
DP[min(n,j+l)][l]+=dp[j][k];
for (j=; j<=n; j++) for (k=; k<=n; k++) {dp[j][k]=DP[j][k];DP[j][k]=;}
}
for (j=; j<=n; j++) ans+=dp[n][j];
cout<<sum<<' '<<ans;
return ;
}
T3动态规划(dp)
不会做30分爆搜
正解:
dp[i][j] 1~i 切了j刀,的最优解
dp[i][j]=min{dp[k][j-1]+sum(k+1,i)}
可以证明这个转移方程具有单调性,zhw说自己yy
20*n^2的简单dp -> 在固定j的情况下 随着i的增大,k不降 ,那么就可分治了
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 1000011
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
using namespace std;
int n, q, ans;
int f[N]; struct node
{
int x, y, z;
}p[N], t[N]; inline int read()
{
int x = , f = ;
char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -;
for(; isdigit(ch); ch = getchar()) x = (x << ) + (x << ) + ch - '';
return x * f;
} inline bool cmp(node x, node y)
{
return x.z > y.z;
} inline int find(int x)
{
return x == f[x] ? x : f[x] = find(f[x]);
} inline bool check(int k)
{
int i, j, x, y, lmin, lmax, rmin, rmax;
for(i = ; i <= n + ; i++) f[i] = i;
for(i = ; i <= k; i++) t[i] = p[i];
std::sort(t + , t + k + , cmp);
lmin = lmax = t[].x;
rmin = rmax = t[].y;
for(i = ; i <= k; i++)
{
if(t[i].z < t[i - ].z)
{
if(find(lmax) > rmin) return ;
for(j = find(lmin); j <= rmax; j++)
f[find(j)] = find(rmax + );
lmin = lmax = t[i].x;
rmin = rmax = t[i].y;
}
else
{
lmin = min(lmin, t[i].x);
lmax = max(lmax, t[i].x);
rmin = min(rmin, t[i].y);
rmax = max(rmax, t[i].y);
if(lmax > rmin) return ;
}
}
// cout<<find(1)<<endl;
if(find(lmax) > rmin) return ;
return ;
} int main()
{
freopen("number.in","r",stdin);
freopen("number.out","w",stdout);
int i, x, y, mid;
n = read();
q = read();
for(i = ; i <= q; i++)
p[i].x = read(), p[i].y = read(), p[i].z = read();
x = , y = q;
//cout<<check(2)<<endl;
//return 0;
ans = q + ;
while(x <= y)
{
mid = (x + y) >> ;
if(check(mid)) ans = mid, y = mid - ;
else x = mid + ;
}
printf("%d\n", ans);
return ;
}
济南day1下午的更多相关文章
- PKUSC 模拟赛 day1 下午总结
下午到了机房之后又困又饿,还要被强行摁着看英文题,简直差评 第一题是NOIP模拟赛的原题,随便模拟就好啦 本人模拟功力太渣不小心打错了个变量,居然调了40多分钟QAQ #include<cstd ...
- 云栖大会day1 下午
下午参与的是创新创业专场 会议议程是 创新创业专场-2018阿里云创新中心年度盛典 13:30-14:10 阿里双创新征程 李中雨 阿里云创业孵化事业部总经理 14:10-14:40 人货场的渗透与重 ...
- Day1下午解题报告
预计分数:0+30+30=60 实际分数:0+30+40=70 T1水题(water) 贪心,按长度排序, 对于第一幅牌里面的,在第二个里面,找一个长度小于,高度最接近的牌 进行覆盖. 考场上的我离正 ...
- 北京DAY1下午
省选模拟题 周子凯 题目概况 中文题目名 简易比特币 计算 路径 英文题目名 bit calculation Path 输入文件名 bit.in calculation.in path.in 输出文件 ...
- Day1下午
T1 暴力50分 排A和B X,不用考虑X 用数组80分, 权值线段树.平衡树100, 一个函数? T2 打表 dp logn+1,+ 搜索,dp? txt..... T3 30分暴力和尽量均 ...
- 济南day1
预计分数:100+100+30 实际分数:10+60+20 T1立方数(cubic) 题目描述 LYK定义了一个数叫“立方数”,若一个数可以被写作是一个正整数的3次方,则这个数就是立方数,例如1,8, ...
- ZJOI2016二试+游记
...excited.... 一场打回原形爽哦. T1莫名爆到了10分,T2T3均没交,一个小时过后就没再拿任何分数,perfectly狗带了... 总之没有给自己充足的时间去敲暴力,ZJOI啊..拿 ...
- Noip2015总结
Noip2015战役总结 [游记部分] Day0 考前说是可以放松一下,下午呢就在机房打了几盘杀,一起玩了玩狼人.不过晚上觉得还是要有点氛围了,于是稍稍打了几个模板,觉得正确率还不错,给自己一点自信的 ...
- 近期概况&总结
下午考完英语的学考就要放假啦,是衡中的假期啊QAQ 所以灰常的激动,一点也不想写题(我不会告诉你其实假期只有一个晚上.. 自从CTSC&APIO回来之后就一直在机房颓颓颓,跟着zcg学了很多新 ...
随机推荐
- nginx的常用负载均衡算法,分别是
随机分配,hash一致性分配,最小连接数分配,主备分配 随机,轮训,一致性哈希,主备,https://blog.csdn.net/liu88010988/article/details/5154741 ...
- [python] 求大神解释下 面向对象中方法和属性
面向对象中 类方法 实例方法 类属性 实例属性该如何理解呢?
- stl vector 类
目录 [-]说明构造方法例子vector 类中定义了4中种构造函数: · 默认构造函数,构造一个初始长度为0的空向量,如:vector<int> v1; · 带有单个整形参数的构造函数,此 ...
- python - work - 2
#-*- coding:utf-8 -*-# author:jiaxy# datetime:2018/11/3 11:48# software: PyCharm Community Edition d ...
- linux快速查看同局域网的其他在线主机
安装一个nmap工具,直接 nmap -sP 192.168.1.1/24 即可
- 【LeetCode】Longest Common Prefix(最长公共前缀)
这道题是LeetCode里的第14道题. 题目描述: 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["f ...
- TensorFlow学习笔记(6):TensorBoard之Embeddings
本文基于TensorFlow官网的How-Tos写成. TensorBoard是TensorFlow自带的一个可视化工具,Embeddings是其中的一个功能,用于在二维或三维空间对高维数据进行探索. ...
- Diango路由控制
路由的格式: #路由配置的格式: urls.py里面写 from diango.conf.urls import url urlpatterns = [ url(正则表达式,views视图函数,nam ...
- Spring事务支持:利用继承简化配置
因为事务代理的实现类是 TransactionProxyFactoryBean . 事务代理Bean必须注入事务管理器. 大部分情况下,每个事务代理的事务属性大同小异,对于这种情况,Spring提供了 ...
- iOS学习笔记47-Swift(七)泛型
一.Swift泛型介绍 泛型是为Swift编程灵活性的一种语法,在函数.枚举.结构体.类中都得到充分的应用,它的引入可以起到占位符的作用,当类型暂时不确定的,只有等到调用函数时才能确定具体类型的时候可 ...