19-10-15-W
暴力终于不跪了$\text{QvQ}$
z总j结
考试开始看到几个大字:Day1
Happy~(××终于不用爆〇了哈哈哈哈!!)
开T1。一看,不是在线仙人球嵌套动态网络路径剖分优化的分支定界贪心剪枝启发式迭代加深人工智能搜索决策算法么……好!
码完一看,过不了大阳历……
关于大阳历,我是这么评价她的……
不给大阳历嫌他不给了,给了又过不了=.=
发现贪心错了。
于是马上……(×××的day1)
看T2。
发现是数学,研究一番,推了一番柿子,然后就弃了。
这时我有点慌了(开考$1h$啥都没打??)
于是马上看T3(?)
暴力好打$\text{QvQ}$
打完T3回去想了下T1
码了一个$\Theta(N^2\log N)$的法子(全是在线仙人球嵌套动态网络路径剖分优化的分支定界贪心剪枝启发式迭代加深人工智能搜索决策算法)
然后T2的暴力也出来了。
最后是……
|
28
|
Miemeng | 70
03:11:56
|
30
03:11:57
|
50
03:11:57
|
150
03:11:57
|
T1
法1
讲个我的$\Theta(N^2\log N)$
想到了让点找段,但是没来得及打。
于是我让段找点。
但是从左往右扫一定会死,因为贪心……
于是我想到可以维护段内的点数来贪。
从内部点数最少的段向更大的段贪。
每次修改都要重新计算和 sort
交上去$70$
(话说为啥本地对拍一直WA)
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <cstdio>
#define N 222222 using namespace std; struct Seg{
int l,r;
int pn;
}dse[N];
int dpo[N],sen,pon,ans=0;
bool is_del[N];
int findv(int val){
return lower_bound(dpo+1,dpo+pon+1,val)-dpo;
}
inline bool CMP(const Seg &a,const Seg &b){
return a.pn<b.pn;
}
int main(){
// freopen("dream.in" ,"r",stdin);\
freopen("dream.out","w",stdout);
scanf("%d%d",&sen,&pon);
for(int i=1;i<=sen;i++)
scanf("%d%d",&dse[i].l,&dse[i].r);
for(int i=1;i<=pon;i++)
scanf("%d",dpo+i);
sort(dpo+1,dpo+pon+1);
for(int i=1;i<=sen;i++){
dse[i].pn=findv(dse[i].r+1)-findv(dse[i].l);
}
sort(dse+1,dse+sen+1,CMP);
for(int i=1;i<=sen;i++){
// cout<<dse[i].l<<" "<<dse[i].r<<" "<<dse[i].pn<<endl;
int l=findv(dse[i].l),
r=findv(dse[i].r+1);
bool is_c=0;
// cout<<"["<<dpo[l]<<","<<dpo[r]<<")"<<endl;
if(l<r){
// cout<<i<<" ++++ "<<endl;
is_c=1;
dpo[l]=INT_MAX;
ans++;
}
if(is_c){
sort(dpo+1,dpo+pon+1);
for(int k=i+1;k<=sen;k++){
dse[k].pn=findv(dse[k].r+1)-findv(dse[k].l);
}
sort(dse+i+1,dse+sen+1,CMP);
}
}
printf("%d\n",ans);
}
正解……
点找段,堆优化……
首先对于每一个懵点,从左到右扫,一定是能覆盖它且右端点更靠左的更优。
于是用堆优化这个过程。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue> #define N 222222 using namespace std; struct Seg{
int l,r;
friend bool operator < (const Seg &a,const Seg &b){
return a.r>b.r;
}
}seg[N];
int sen,pn;
void pour(priority_queue<Seg>s){
puts("---------===VV===----------");
while(!s.empty()){
cout<<s.top().l<<" "<<s.top().r<<endl;
s.pop();
}
puts("---------===^^===----------");
}
priority_queue<Seg>q;
int po[N],ans=0;
int main(){
scanf("%d%d",&sen,&pn);
for(int i=1;i<=sen;i++)
scanf("%d%d",&seg[i].l,&seg[i].r);
for(int i=1;i<=pn;i++)
scanf("%d",po+i);
sort(po+1,po+pn+1);
sort(seg+1,seg+sen+1,[](const Seg &a,const Seg &b){return a.l<b.l;});
int sid=1;
for(int i=1;i<=pn;i++){
while(sid<=sen && seg[sid].l<=po[i])q.push(seg[sid]),sid++;
while(!q.empty() && q.top().r<po[i])q.pop();
if(!q.empty() && q.top().l<=po[i] && po[i]<=q.top().r){
ans++;
q.pop();
}
}
printf("%d\n",ans);
}
T2
很显然(不会)的$dp$
T3
莫队直接过,$\Theta(1)$转移一下就好了。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define N 222222 using namespace std; struct Query{
int l,r;
int id;
}qs[N];
struct SR{
int next,t;
}rs[2*N];
int pn,qn,
fl[N],
inp[N],
ans[N],
fa[N],
ason[N],
pl,
nans,
cnt=0;
bool isc[N]; inline bool CMP(const Query &a,const Query &b){
return inp[a.l]==inp[b.l]?(inp[a.l]&1?a.r<b.r:a.r>b.r):inp[a.l]<inp[b.l];
}
void add(int f,int t){
rs[cnt].t=t;
rs[cnt].next=fl[f];
fl[f]=cnt++;
}
void dfs(int k,int pre){
for(int i=fl[k];i!=-1;i=rs[i].next){
int t=rs[i].t;
if(t!=pre){
fa[t]=k;
dfs(t,k);
}
}
}
void add(int id){
ason[fa[id]]++;
nans-=ason[id]+isc[fa[id]]-1;
isc[id]=true;
}
void del(int id){
ason[fa[id]]--;
nans+=ason[id]+isc[fa[id]]-1;
isc[id]=false;
}
int main(){
int a,b;
memset(fl,-1,sizeof fl);
scanf("%d%d",&pn,&qn);pl=sqrt(pn)+1;
for(int i=1;i<=pn;i++)
inp[i]=(i-1)/pl+1;
for(int i=1;i<pn;i++){
scanf("%d%d",&a,&b);
add(a,b);
add(b,a);
}
dfs(1,0);
for(int i=1;i<=qn;i++){
scanf("%d%d",&qs[i].l,&qs[i].r);
qs[i].id=i;
}
sort(qs+1,qs+qn+1,CMP);
int l=1,r=1;
add(1);
for(int i=1;i<=qn;i++){
while(l>=qs[i].l){
l--;
add(l);
}
while(r<=qs[i].r){
r++;
add(r);
}
while(l<qs[i].l){
del(l);
l++;
}
while(r>qs[i].r){
del(r);
r--;
}
ans[qs[i].id]=nans;
}
for(int i=1;i<=qn;i++)
printf("%d\n",ans[i]);
}
19-10-15-W的更多相关文章
- 程序员的 Ubuntu 19.10 配置与优化指南
原文地址:程序员的 Ubuntu 19.10 配置与优化指南 0x00 环境 CPU: Intel Core i9-9900k GPU: GeForce RTX 2070 SUPER RAM: DDR ...
- 7.12-7.19 id、w、who、last、lastb、lastlog
7.12-7.19 id.w.who.last.lastb.lastlog 目录 7.12 id:显示用户与用户组的信息 7.13 w:显示已登录用户信息 7.14 who:显示已登录用户信息 显示最 ...
- CVE-2015-1328 Ubuntu 12.04, 14.04, 14.10, 15.04 overlayfs Local Root
catalog . 引言 . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch ...
- macOS 10.15 Catalina Apache设置:多个PHP版本
第1部分:macOS 10.15 Catalina Web开发环境 在macOS上开发Web应用程序真是令人高兴.有许多设置开发环境的选项,包括广受欢迎的MAMP Pro,它在Apache,PHP和M ...
- 背水一战 Windows 10 (15) - 动画: 缓动动画
[源码下载] 背水一战 Windows 10 (15) - 动画: 缓动动画 作者:webabcd 介绍背水一战 Windows 10 之 动画 缓动动画 - easing 示例演示缓动(easing ...
- Linux Kernel 3.11.4/3.10.15/3.4.65/3.0.99
Linux 今天又发布了4个更新版本,分别是: 3.11.4 2013-10-05 [tar.xz] [pgp] [patch] [view patch] [view inc] [cgit] [cha ...
- WTL汉化版2013.10.15
汉化内容: 2013.10.15 版本:当前可下载Trunk最新版,wtl-code-467-trunk.zip 汉化内容: 1.应用向导的部分汉化,考虑到部分词汇的表述问题,只汉化无影响部分 2.资 ...
- [Mon Feb 10 15:21:06 2014] [notice] child pid 7101 exit signal File size limit exceeded (25)
今天遇到的问题: LAMP的LOG里报如下错误. 然后IE和FIREFOX里显示连接被重置或是无法访问. 但自己建一个正常的PHP测试探针倒可以. 原来是PHP错误日志太多,无法写入LOG导致. [r ...
- Datatables插件1.10.15版本服务器处理模式ajax获取分页数据实例解析
一.问题描述 前端需要使用表格来展示数据,找了一些插件,最后确定使用dataTables组件来做. 后端的分页接口已经写好了,不能修改.接口需要传入页码(pageNumber)和页面显示数据条数(pa ...
- Ubuntu 19.10 发布 | 云原生生态周报 Vol. 24
作者 | 木苏.进超.冬岛.元毅.心水.衷源 业界要闻 1.云原生编程语言 Pulumi 1.0 pulumi ,一款中立的开源云开发平台,Pulumi 支持多语言.混合云环境.完全可扩展.初期支持 ...
随机推荐
- 14 win7 sp1下安装vs2015
0 引言 在win7下安装vs2015的时候遇到了很多问题,看了很多帖子,尝试了很多次,终于成功了.网上也有大量关于win7 sp1下安装vs2015的帖子,我在安装的时候也参考了很多相关经验,这次写 ...
- python截图+百度ocr(图片识别)+ 百度翻译
一直想用python做一个截图并自动翻译的工具,恰好最近有时间就在网上找了资料,根据资料以及自己的理解做了一个简单的截图翻译工具.整理一下并把代码放在github给大家参考.界面用python自带的G ...
- npm run server报错
从git上clone的vue项目npm install后npm run server报错 $ npm run dev > lufei@1.0.0 dev E:\pythonProject\luf ...
- 常用css初始化样式(淘宝)
最简单粗暴的css初始化样式就是:*{padding:0:margin:0}(不推荐) 淘宝的样式初始化: body, h1, h2, h3, h4, h5, h6, hr, p, blockquot ...
- ReadyAPI创建功能测试的多种方法
原文:ReadyAPI创建功能测试的多种方法 声明:如果你想转载,请标明本篇博客的链接,请多多尊重原创,谢谢! 本篇使用的 ReadyAPI版本是2.5.0 在ReadyAPI中有多种方法可以创建功能 ...
- select函数使用
这两天写了这么一段代码,select直接返回-1,错误信息是“invalid argments”,显然没有达到阻塞超时的效果. 代码如下: bool IsSocketWaitRead(inf fd,i ...
- 关系型数据库——MySQL
[MySQL架构图] MySQL简要架构图如下图所示,引擎层以插件方式集成了不同的存储引擎,它们共用Server层对外提供服务. 连接器:用于连接管理,进行身份认证及权限相关的管理.(登录MySQ ...
- 移动端,fixed bottom问题
//不显示 .bar { position:fixed; bottom:0; z-index:99; } //显示 .bar{ position:fixed; bottom:calc(90vh); / ...
- Composer环境混乱引起--Fatal error: Call to undefined method Fxp
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\V ersionParser::parse ...
- memcache课程---3、php使用memcache缓存实例
memcache课程---3.php使用memcache缓存实例 一.总结 一句话总结: 前置:windows下安装好memcache.exe,安装好memcache的php扩展,开启memcache ...