19-11-08-Night
再咕咕咕会被爆捶吗???
ZJ:
喜闻乐见:
|
27
|
Miemeng | 60
01:59:43
|
100
01:59:44
|
0
01:59:44
|
160
01:59:44
|
最水的$T1$挂了????
$T2$乱搞直接$A$????
$T3$为什么是$0$,暴力又跪了??
$kuku$
TJ解:
T1:
合并石子,初始化集合大小(或者打记忆化)
先拆环。
好像就没啥了。
话说我T1为什么只枚举到$n$,我明明拆环了啊?我双神志不清了???
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 333 using namespace std; int dp[2*N][2*N];
int arr[N*2],nn;
int val[2*N][2*N],nval[N];
int ans=0; int vlnum(int l,int r){
if(val[l][r])return val[l][r];
int vn=0;
for(int i=l;i<=r;i++){
if(nval[arr[i]]==0)vn++;
nval[arr[i]]++;
}
for(int i=l;i<=r;i++)
nval[arr[i]]--;
return val[l][r]=vn;
}
inline int getval(int l1,int r1,int l2,int r2){
return vlnum(l1,r1)*vlnum(l2,r2);
}
int main(){
#ifndef LOCAL
freopen("merge.in" ,"r",stdin);
freopen("merge.out","w",stdout);
#endif
scanf("%d",&nn);
for(int i=1;i<=nn;i++){
scanf("%d",arr+i);
arr[nn+i]=arr[i];
}
for(int len=0;len<nn;len++){
for(int l=1;l+len<=2*nn;l++){
int r=l+len;
for(int k=l;k<r;k++){
dp[l][r]=max(dp[l][r],dp[l][k]+dp[k+1][r]+getval(l,k,k+1,r));
}
}
}
for(int i=1;i<=nn;i++){
ans=max(dp[i][i+nn-1],ans);
}
cout<<ans<<endl;
}
T2
正解是枚举最后一嗑药,$\mathsf{ST}$表维护查询。
$\Theta(N \log N)$
这里我安利一下我的乱搞。
首先维护一个堆(以$A-B$ [上升高度] 为关键字的大根堆)「堆1」
然后再来一个(以$A$为关键字的大根堆)「堆2」
然后每次先从堆2中查一下能不能一发入魂,
如果已经嗑掉了,那么我们考虑反悔,把当时嗑掉的吐出来,用当前堆1顶的弥补一下。
如果加上弥补也上不去那就扔掉(其实这里是伪的,扔掉的有时候在后面反悔是正确的(捂脸)
如果没有嗑掉,我们试试嗑一下,如果出去了就嗑。
如果怎么都上不去,我W们M就J从堆1中取一个药并嗑掉,
如果在这时被淹死了,那一定死了,因为别的也不可能上升更高。
于是过不了对拍,
配上暴力及特殊性质食用。
于是AC了???
请大佬们随意Hack(汗可,亥可):
//climb #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define N 111111 using namespace std; int dn,hei;
struct YW{
int up,down;
}ys[N];
int upw[N],per[N];
int ans=0x7fffffff;
struct A_MAX{
int up,down,id;
A_MAX(){}
A_MAX(const YW a,int b){up=a.up,down=a.down,id=b;}
friend bool operator < (const A_MAX &a,const A_MAX &b){
return a.up<b.up;
}
};
struct Del_MAX{
int up,down,id;
Del_MAX(){}
Del_MAX(const YW a,int b){up=a.up,down=a.down,id=b;}
friend bool operator < (const Del_MAX &a,const Del_MAX &b){
return a.up-a.down<b.up-b.down;
}
};
bool is_del[N];
priority_queue<A_MAX>aq;
priority_queue<Del_MAX>dq;
namespace B_eq_0{
inline bool CMP(const YW &a,const YW &b){
return a.up>b.up;
}
void work(){
sort(ys+1,ys+dn+1,CMP);
int pos=0,wpos=0;
for(int i=1;i<=dn;i++){
pos+=ys[i].up;
if(pos>=hei){
printf("%d\n",i);
return ;
}
wpos+=upw[i];
if(pos<=wpos){
puts("-1");
return ;
}
}
puts("-1");
return ;
}
}
namespace C_eq_0{
void work(){
for(int i=1;i<=dn;i++){
aq.push( A_MAX(ys[i],i));
dq.push(Del_MAX(ys[i],i));
}
int pos=0;
for(int i=1;i<=dn;i++){
while(is_del[aq.top().id] && pos+aq.top().down+dq.top().up-dq.top().down < hei){
aq.pop();
}
if(is_del[aq.top().id]){
printf("%d\n",i);
return;
}
else if(!is_del[aq.top().id] && aq.top().up+pos>=hei){
printf("%d\n",i);
return;
}
pos+=dq.top().up;
pos-=dq.top().down;
is_del[dq.top().id]=1;
dq.pop();
}
puts("-1");
return ;
}
}
int getans(){
int pos=0,wtpos=0;
for(int i=1;i<=dn;i++){
pos+=ys[per[i]].up;
if(pos>=hei)
return i;
pos-=ys[per[i]].down;
wtpos+=upw[i];
if(pos<=wtpos)return 0x7fffffff;
}
return 0x7fffffff;
} int main(){
#ifndef LOCAL
freopen("climb.in" ,"r",stdin);
freopen("climb.out","w",stdout);
#endif
bool down_0=1,upw_0=1;
scanf("%d%d",&dn,&hei);
for(int i=1;i<=dn;i++){
per[i]=i;
scanf("%d%d",&ys[i].up,&ys[i].down);
if(ys[i].down!=0)down_0=0;
}
for(int i=1;i<=dn;i++){
scanf("%d",upw+i);
if(upw[i]!=0)upw_0=0;
}
if(dn<=10){
do{
ans=min(ans,getans());
}while(next_permutation(per+1,per+dn+1));
printf("%d\n",ans>dn?-1:ans);
return 0;
}
if(down_0) B_eq_0::work();
else if(upw_0)C_eq_0::work();
else{
for(int i=1;i<=dn;i++){
aq.push( A_MAX(ys[i],i));
dq.push(Del_MAX(ys[i],i));
}
int pos=0,wpos=0;
for(int i=1;i<=dn;i++){
while(is_del[aq.top().id] && pos+aq.top().down+dq.top().up-dq.top().down < hei){
aq.pop();
}
if(is_del[aq.top().id]){
printf("%d\n",i);
return 0;
}
else if(!is_del[aq.top().id] && aq.top().up+pos>=hei){
printf("%d\n",i);
return 0;
}
pos+=dq.top().up;
if(pos>=hei){
printf("%d\n",i);
return 0;
}
pos-=dq.top().down;
wpos+=upw[i];
// cout<<pos<<" "<<wpos<<endl;
if(pos<=wpos)break;
is_del[dq.top().id]=1;
dq.pop();
}
puts("-1"); }
}
UPD:T3不会
19-11-08-Night的更多相关文章
- Update 19.11 for Azure Sphere
今天,微软发布了面向Azure Sphere的19.11更新,其主要亮点就是加入了对开发工具Visual Studio Code和Linux开发环境的支持.具体来讲,本次更新包含3个部分: 1. Az ...
- 爬虫基础学习 转【http://www.cnblogs.com/huangxincheng/archive/2012/11/08/2759752.html】
这一篇我们聊聊在页面抓取时应该注意到的几个问题. 一:网页更新 我们知道,一般网页中的信息是不断翻新的,这也要求我们定期的去抓这些新信息,但是这个“定期”该怎么理解,也就是多长时间需要 抓一次该页面, ...
- <转载>C#与JAVA的区别 http://www.cnblogs.com/Asa-Zhu/archive/2012/11/08/2761114.html
C#(C-Sharp)是Microsoft的新编程语言,被誉为“C/C++家族中第一种面向组件的语言”.然而,不管它自己宣称的是什么,许多人认为C#更像是Java的一种克隆,或者是Microsoft用 ...
- HDU6029 Happy Necklace 2017-05-07 19:11 45人阅读 评论(0) 收藏
Happy Necklace Time Limit: ...
- NOIP2018赛前停课集训记(10.24~11.08)
前言 为了不久之后的\(NOIP2018\),我们的停课从今天(\(Oct\ 24th\))起正式开始了. 本来说要下周开始的,没想到竟提早了几天,真是一个惊喜.毕竟明天有语文考试.后天有科学考试,逃 ...
- MIT JOS学习笔记03:kernel 02(2016.11.08)
未经许可谢绝以任何形式对本文内容进行转载! 本篇接着上一篇对kernel的分析. (5)pte_t * pgdir_walk(pde_t *pgdir, const void *va, int cre ...
- hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏
huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...
- Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- MiniProfiler使用点滴记录-2017年6月23日11:08:23
1.看似针对同样一段查询表ef达式,重复执行却没有被记录下来.其实这是正常情况,因为ef并没有重复去执行 相同sql查询. 2.MiniProfiler结合MVC过滤器进行 拦截记录Sql,示例代码: ...
- Unity进阶----Lua语言知识点(2018/11/08)
国内开发: 敏捷开发: 集中精力加班堆出来第一个版本 基本没啥大的bug 国外开发: 1).需求分析: 2).讨论 3).分模块 4).框架 5).画UML图(类图class function)(e- ...
随机推荐
- 《转》python 9 字典,numpy
http://www.cnblogs.com/BeginMan/p/3156960.html 一.映射类型 我理解中的映射类型是:键值对的关系,键(key)映射值(value),且它们是一对多的关系. ...
- 十个非常实用的MySQL命令
建赟 版主 楼主 前言 今天介绍一些MySQL常用的实用命令,都是一些比较简单的命令.已经知道的朋友,就当是巩固吧,不知道的童鞋,可以好好在自己的机器上,练习下. 0. 显示数据库 命令:s ...
- java 冒泡排序法、选择排序
1.冒泡排序 /* * 冒泡排序 * 外层控制循环多少趟,内层控制每一趟的循环次数 */ public class Test08 { public static void main(String[] ...
- js正则表达式常见面试题
1 . 给一个连字符串例如:get-element-by-id转化成驼峰形式. var str = "get-element-by-id"; var reg = /-\w/g; / ...
- xx市xx项目运维工作方案
注:提供给各位正在做项目,或准备做项目的朋友,仅供参考,用于后期运维提供的方案模板.仅供参考. 因为直接从word复制,会有一些排版的问题.可以留邮箱. xx市xx项目运维工作方案 xx有限公司 20 ...
- JS对象 指定分隔符连接数组元素join() join()方法用于把数组中的所有元素放入一个字符串。元素是通过指定的分隔符进行分隔的。
指定分隔符连接数组元素join() join()方法用于把数组中的所有元素放入一个字符串.元素是通过指定的分隔符进行分隔的. 语法: arrayObject.join(分隔符) 参数说明: 注意:返回 ...
- FaceNet pre-trained模型以及FaceNet源码使用方法和讲解
Pre-trained models Model name LFW accuracy Training dataset Architecture 20180408-102900 0.9905 CASI ...
- animation,transition,transform小练习
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Java迷宫代码,深度优先遍历
此次迷宫深度优先遍历寻找路径采用栈结构,每个节点都有固定的行走方向(右下左上),除非一个方向走不通,不然会一条道走到黑. 如果路径存在,打印出行走路径,否则打印出迷宫不存在有效路径. 方向常量定义: ...
- jquery高级编程学习
jquery高级编程 第1章.jQuery入门 类型检查 对象 类型检查表达式 String typeof object === "string" Number typeof ob ...