https://www.luogu.org/problemnew/show/3954

https://www.luogu.org/problemnew/show/3955

https://www.luogu.org/problemnew/show/3956

https://www.luogu.org/problemnew/show/3957

T1

甚至不想用c++写

a,b,c=map(int,input().split(' '))
print((a+a+b+b+b+c+c+c+c+c)//10)

T2

乱水

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#define rg register
#define il inline
#define vd void
il int gi(){
rg int x=0;rg bool flg=0;rg char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=1;ch=getchar();}
while(isdigit(ch))x=x*10-'0'+ch,ch=getchar();
return flg?-x:x;
}
int ans[10000001];
il vd checkmn(int&a,int b){if(b<a)a=b;}
int main(){
// freopen("librarian.in","r",stdin);
// freopen("librarian.out","w",stdout);
int n=gi(),orz,q=gi();
for(rg int i=0;i<10000001;++i)ans[i]=19260817;
while(n--){
orz=gi();
checkmn(ans[orz],orz);
checkmn(ans[orz%10000000],orz);
checkmn(ans[orz%1000000],orz);
checkmn(ans[orz%100000],orz);
checkmn(ans[orz%10000],orz);
checkmn(ans[orz%1000],orz);
checkmn(ans[orz%100],orz);
checkmn(ans[orz%10],orz);
}
for(rg int i=0;i<10000001;++i)if(ans[i]==19260817)ans[i]=-1;
while(q--)gi(),orz=gi(),printf("%d\n",ans[orz]);
return 0;
}

T3

dij

还有BFS/SPFA/DFS/DP...

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#include<queue>
#include<cstring>
#define rg register
#define il inline
#define vd void
il int gi(){
rg int x=0;rg bool flg=0;rg char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=1;ch=getchar();}
while(isdigit(ch))x=x*10-'0'+ch,ch=getchar();
return flg?-x:x;
}
const int maxn=101;
int col[maxn][maxn];
struct orzyyb{int x,y;bool col;};
int f[maxn][maxn][2];
bool vis[maxn][maxn][2];
il bool operator <(const orzyyb&a,const orzyyb&b){return f[a.x][a.y][a.col]>f[b.x][b.y][b.col];}
std::priority_queue<orzyyb>que;
const int X[]={0,0,0,1,-1},Y[]={0,1,-1,0,0};
int main(){
// freopen("chess.in","r",stdin);
// freopen("chess.out","w",stdout);
int n=gi(),m=gi();
int x,y,xx,yy,c;
memset(col,-1,sizeof col);
memset(f,63,sizeof f);
while(m--)x=gi(),y=gi(),col[x][y]=gi();
que.push((orzyyb){1,1,(bool)col[1][1]});
f[1][1][col[1][1]]=0;
orzyyb p;
while(!que.empty()){
p=que.top();que.pop();
x=p.x,y=p.y,c=p.col;
if(vis[x][y][c])continue;
vis[x][y][c]=1;
for(rg int i=1;i<5;++i){
xx=x+X[i],yy=y+Y[i];
if(xx<1||xx>n||yy<1||yy>n)continue;
if(~col[xx][yy]){
if(f[xx][yy][col[xx][yy]]>f[x][y][c]+(c^col[xx][yy])){
f[xx][yy][col[xx][yy]]=f[x][y][c]+(c^col[xx][yy]);
que.push((orzyyb){xx,yy,(bool)col[xx][yy]});
}
}else if(~col[x][y]){
if(f[xx][yy][0]>f[x][y][c]+(c^0)+2){
f[xx][yy][0]=f[x][y][c]+(c^0)+2;
que.push((orzyyb){xx,yy,0});
}
if(f[xx][yy][1]>f[x][y][c]+(c^1)+2){
f[xx][yy][1]=f[x][y][c]+(c^1)+2;
que.push((orzyyb){xx,yy,1});
}
}
}
}
int ans=std::min(f[n][n][0],f[n][n][1]);
if(ans==1061109567)ans=-1;
printf("%d\n",ans);
return 0;
}

T4

太套路了

显然答案单调,所以二分k

check用动态规划

一个状态到下一个状态,转移过来的区间会右移(不会左移),所以单调队列优化

套路的死

PS.check加个优化快一倍

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#define rg register
#define il inline
#define vd void
typedef int mainint;
#define int long long
il int gi(){
rg int x=0;rg bool flg=0;rg char ch=getchar();
while(!isdigit(ch)){if(ch=='-')flg=1;ch=getchar();}
while(isdigit(ch))x=x*10-'0'+ch,ch=getchar();
return flg?-x:x;
}
const int maxn=500010;
int n,x[maxn],s[maxn];
il bool dp(int l,int r,int k){
--k;
static int f[maxn],que[maxn];
int hd=0,tl=0,q=1,ret=-1e18;
for(rg int i=1;i<=n;++i){
while(x[i]-x[q]>=l){
while((hd^tl)&&f[que[tl-1]]<=f[q])--tl;
que[tl++]=q++;
}
while((hd^tl)&&x[i]-x[que[hd]]>r)++hd;
if(x[i]>=l&&x[i]<=r)f[i]=s[i];
else f[i]=-1e18;
if(hd^tl)f[i]=std::max(f[i],f[que[hd]]+s[i]);
if(f[i]>k)return 0;
}
return 1;
}
mainint main(){
// freopen("jump.in","r",stdin);
// freopen("jump.out","w",stdout);
n=gi();
int d=gi(),k=gi();
for(rg int i=1;i<=n;++i)x[i]=gi(),s[i]=gi();
if(dp(1,x[n],k)){puts("-1");return 0;}
int l=0,r=x[n],mid;
while(l<r){
mid=(l+r)>>1;
if(dp(std::max(1ll,d-mid),std::min(d+mid,x[n]),k))l=mid+1;
else r=mid;
}
printf("%lld\n",l);
return 0;
}

noip2017普及题解的更多相关文章

  1. NOIP2017普及组解题报告

    刚参加完NOIP2017普及,只考了210,于是心生不爽,写下了这篇解题报告...(逃 第一次写博,望dalao们多多指导啊(膜 第一题score,学完helloworld的人也应该都会吧,之前好多人 ...

  2. noip2017普及 兔纸游玩记

    初中的最后一场比赛...就这样结束了吧...QAQ时间...真够快的qwq 应该是初中的最后一篇游记了吧,尽量写多点... 这是一篇,初三 老年菜兔的 noip2017 普及游玩记吧! DAY 0  ...

  3. [NOIP2017普及组]跳房子(二分,单调队列优化dp)

    [NOIP2017普及组]跳房子 题目描述 跳房子,也叫跳飞机,是一种世界性的儿童游戏,也是中国民间传统的体育游戏之一. 跳房子的游戏规则如下: 在地面上确定一个起点,然后在起点右侧画 nn 个格子, ...

  4. 「LOJ 6373」NOIP2017 普及组题目大融合

    NOIP2017 普及组题目大融合 每个读者需要有某个后缀的书,可以暴力map,复杂度\(o(9*nlog(n))\),也可以反串建trie树,复杂度\(o(9*n)\). 故可以求出需要的最少的RM ...

  5. P3956 [NOIP2017 普及组] 棋盘

    P3956 [NOIP2017 普及组] 棋盘 题目 题目描述 有一个 m×m 的棋盘,棋盘上每一个格子可能是红色.黄色或没有任何颜色的.你现在要从棋盘的最左上角走到棋盘的最右下角. 任何一个时刻,你 ...

  6. NOIP2017普及组T2题解

    还是神奇的链接 上面依然是题目. 这道题依然很简单,比起2015年的普及组t2好像还是更水一些. 不过这道题能讲的比第一题多. 我们一起来看一下吧! 这一题,我们首先将书的编号全部读入,存在一个数组里 ...

  7. NOIP2017普及组T1题解

    神奇的链接 上面时题目. 其实不得不说,这一题很水,比2015年的第一题水多了. 直接按题目套公式就行了,当然你也可以像我一样化简一下. 直接看代码: #include<cstdio> # ...

  8. NOIP2017普及组比赛总结

    期中考总结&NOIP2017总结 2017年11月11日,我第二次参加NOIP普及组复赛.上一年,我的得分是250分,只拿到了二等奖.我便把目标定为拿到一等奖,考到300分以上. 早上8点多, ...

  9. NOIP2017 列队 题解报告【56行线段树】

    题目描述 Sylvia 是一个热爱学习的女♂孩子. 前段时间,Sylvia 参加了学校的军训.众所周知,军训的时候需要站方阵. Sylvia 所在的方阵中有n \times mn×m名学生,方阵的行数 ...

随机推荐

  1. 滑动cell的时候执行动画效果

    滑动cell的时候执行动画效果 效果图: 源码: // // ViewController.m // AniTab // // Created by XianMingYou on 15/2/26. / ...

  2. RAID廉价磁盘冗余阵列介绍

    RAID(廉价磁盘冗余阵列)技术主要是为了改善磁盘的访问延迟,增强磁盘的可用性和容错能力.目前服务器级别的计算机都支持插入多块磁盘(8块或者更多),通过使用RAID技术,实现数据在多块磁盘上的并发读写 ...

  3. arcgis 10.1 导入数据到oracle 发布地图服务

    机器配置说明 数据库服务器 系统:linux 软件:oracle 11G 64位 Arcgis server服务器 系统:win7 专业版 软件:arcgis server 10.1.win64_11 ...

  4. swift的异常处理:本质是错误信息的传递方式

    func response(from resultObject: Any) throws -> Response { guard let dict = resultObject as? [Str ...

  5. struts2中的文件上传和下载

    天下大事,必做于细.天下难事,必作于易. 以前见过某些人,基础的知识还不扎实就去学习更难的事,这样必定在学习新的知识会非常迷惑结果 再回来又一次学习一下没有搞懂的知识,这必定会导致学习效率的下降!我写 ...

  6. 20165318 2017-2018-2 《Java程序设计》第四周学习总结

    20165318 2017-2018-2 <Java程序设计>第四周学习总结 IDEA安装 按照娄老师Intellj IDEA 简易教程,我下载了IDEA但是由于没有注册学校邮箱,我没办法 ...

  7. [luogu3943] 星空

    题面 ​ 这个题目大意上是这样的:给定一个长度为n的01串, 其中只有k个0, 每次操作时, 从给定的m种长度中选择一种, 选择序列上长度为这种的进行反转操作, 求至少需要多少次操作使得整个串全变为1 ...

  8. Redis基本数据类型命令汇总

    前言   前阶段写Redis客户端作为学习和了解Redis Protocol,基本上把Strintg,List,Hash,Set,SortedSet五种基础类型的命令都写完了,本篇进行总结,也相当于复 ...

  9. App性能测试-GT

    无意之间发现了GT(随身调)这个性能测试工具,该工具是由腾讯出品的开源测试工具,直接运行在手机上的“集成调测环境”. 1.下载:下载地址:开源地址:https://github.com/Tencent ...

  10. (未解决)记录一次登录&jmeter,留下的一地鸡毛

    一般的登录校验过程是这样的:客户端发起请求,拿到服务器给的“令牌”,再次发起请求,服务器验证“令牌”是否正确,从而返回给客户端是登录成功还是登录失败.然后我按照这个流程,用jmeter去模拟了登录过程 ...