T1.exercise

题解

数据很小直接模拟

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<map>
#define ll long long
using namespace std;
int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,m;
int a[2005];
int main()
{
freopen("exercise.in","r",stdin);
freopen("exercise.out","w",stdout);
for(int i=1;i<=1440;i++)a[i]=1;
n=read();m=read();
for(int i=1;i<=m;i++)
{
char ch[25];
scanf("%s",ch);
int l=read(),r=read(),v=read();
for(int j=l;j<=r;j++)a[j]-=v;
}
int sum=n;
for(int i=1;i<=1440;i++)
{
sum+=a[i];
if(sum<=0){printf("Runtime Error\n%d\n",i);return 0;}
}
puts("Accepted");
printf("%d",sum);
return 0;
}

T2.catclimb

题解

迭代深搜,最好先排个序。。。

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<map>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
bool flag;
int n,w,deep,sum;
int c[20],b[20];
void dfs(int x)
{
if(x==n+1){flag=1;return;}
for(int i=1;i<=deep;i++)
if(b[i]+c[x]<=w)
{
b[i]+=c[x];
dfs(x+1);
b[i]-=c[x];
if(flag)return;
}
return;
}
int main()
{
freopen("catclimb.in","r",stdin);
freopen("catclimb.out","w",stdout);
n=read();w=read();
for(int i=1;i<=n;i++)c[i]=read(),sum+=c[i];
sort(c+1,c+n+1,greater<int>());
for(deep=sum/w;deep<=18;deep++)
{
dfs(1);
if(flag)
{
printf("%d\n",deep);
return 0;
}
}
return 0;
}

T3.war

题解

部分分快排。。

正解平衡树

AC代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<map>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int tmp;
int n,m,root,size;
int b[300005],v[300005],w[300005],s[300005],rnd[300005];
int ls[300005],rs[300005];
bool tag[300005];
void update(int k){s[k]=s[ls[k]]+s[rs[k]]+w[k];}
void rturn(int &k)
{int t=ls[k];ls[k]=rs[t];rs[t]=k;update(k);update(t);k=t;}
void lturn(int &k)
{int t=rs[k];rs[k]=ls[t];ls[t]=k;update(k);update(t);k=t;}
void insert(int &k,int num)
{
if(!k){k=++size;rnd[k]=rand();w[k]=s[k]=1;v[k]=num;return;}
s[k]++;
if(num==v[k]){w[k]++;return;}
else if(num<v[k]){insert(ls[k],num);if(rnd[ls[k]]<rnd[k])rturn(k);}
else {insert(rs[k],num);if(rnd[rs[k]]<rnd[k])lturn(k);}
}
void del(int &k,int num)
{
if(!k)return;
if(num==v[k])
{
if(w[k]>1){w[k]--;s[k]--;return;}
if(ls[k]*rs[k]==0)k=ls[k]+rs[k];
else if(rnd[ls[k]]<rnd[rs[k]]){rturn(k);del(k,num);}
else {lturn(k);del(k,num);}
}
else if(num<v[k])
{del(ls[k],num);s[k]--;}
else {del(rs[k],num);s[k]--;}
}
int query(int k,int x)
{
if(!k)return -1;
if(s[ls[k]]>=x)return query(ls[k],x);
else if(x>s[ls[k]]+w[k])return query(rs[k],x-w[k]-s[ls[k]]);
else return k;
}
int main()
{
freopen("war.in","r",stdin);
freopen("war.out","w",stdout);
n=read();
for(int i=1;i<=n;i++)b[i]=read();
for(int i=1;i<=n;i++)insert(root,b[i]);
m=read();
int k,x;
for(int i=1;i<=m;i++)
{
char ch[2];
scanf("%s",ch);
if(ch[0]=='A')
{
k=read();x=read();
del(root,b[k]);b[k]-=x;
if(b[k]>0)insert(root,b[k]);
else n--;
}
else if(ch[0]=='C')
{
k=read();x=read();
del(root,b[k]);b[k]+=x;
insert(root,b[k]);
}
else
{
k=read();
if(k>n)puts("-1");
else printf("%d\n",v[query(root,n-k+1)]);
}
}
printf("%d\n",n);
return 0;
}

18年10月31日 NOIP模拟赛的更多相关文章

  1. 18年10月30日 NOIP模拟赛

    T1 jkl 题解 显然每次都取a[i]的最大值/最小值,并更新a[i]即可 用数据结构维护这一操作..得分看常数 事实上用v[i]记录权值为i的个数,然后for乱搞就可以了... 其它乱搞做法能获得 ...

  2. 18年11月5日 NOIP模拟赛

    T1 题解 对于k=100的情况,贪心 对于100%的数据 可以发现,当前的决策只对后面的开采有影响,且剩余耐久度与之后的开采收益成正比,如果倒着考虑这个问题,得出i-n的星球1点耐久度所能获得的最大 ...

  3. 9月24日noip模拟赛解题报告

    1.校门外的树(tree.c/cpp/pas 128M,1s) Description LSGJ扩建了,于是校门外有了一条长为L的路.路上种了一排的树,每相邻两棵树之间的距离为1,我们可以把马路看成一 ...

  4. 2016年10月31日 星期一 --出埃及记 Exodus 19:16

    2016年10月31日 星期一 --出埃及记 Exodus 19:16 On the morning of the third day there was thunder and lightning, ...

  5. 2017年10月31日结束Outlook 2007与Office 365的连接

    2017 年10月31日 ,微软即将推出 Office 365中Exchange Online邮箱将需要Outlook for Windows的连接,即通过HTTP Over MAPI方式,传统使用R ...

  6. 中国省市县数据库sql文件(2017年10月31日之前)

    摘自国家统计局 sql文件下载地址:https://files.cnblogs.com/files/zxj95121/%E7%9C%81%E5%B8%82%E5%8E%BFsql.zip 2019.4 ...

  7. 易初大数据 spss 2019年10月31日 wangqingchao

    ---恢复内容开始--- 1.描述性统计分析方法是指应用分类.制表.图形及概括性数据指标来概括数据分析特征的方法. 2.而推断性统计分析方法则是通过随机抽样,应用统计方法把从样本数据得到的结论推广到总 ...

  8. Techparty-广州 10 月 31 日 Docker 专场沙龙 后记

    华为的童鞋技术能力很强,但是两位讲师的都没听进去.重点听了两个,一个是芒果TV的Docker 之路,另一个是Coding的实践和思考. 芒果TV的主讲人是一直仰慕的CMGS,从豆瓣出来后去了国企芒果台 ...

  9. 2016年10月31日--网页 Windows对象操作

    Window.opener:打开当前窗口的源窗口,如果当前窗口是首次启动浏览器打开的,则opener是null. Window.open(URL,name,features,replace):open ...

随机推荐

  1. cordova打包APK,SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode ...

    javascript 严格模式 第一次接触let关键字,有一个要非常非常要注意的概念就是”javascript 严格模式”,比如下述的代码运行就会报错: let hello = 'hello worl ...

  2. C# 获取config文件的值

    自定义配置文件帮助类 利用ExeConfigurationFileMap类将自定义配置文件转换为Configuration类进行数据读取 代码很简单,就不做扼要说明 /// <summary&g ...

  3. @Html.Raw()用法和Html.ActionLink的用法总结

    @Html.Raw() 方法输出带有html标签的字符串, 如:@Html.Raw("<div style='color:red'>输出字符串</div>" ...

  4. 面试7 GC机制中如何判断一个对象是否任在使用

    GC 通过在使用的根引用遍历所有引用的对象实例,当一个对象不能被遍历时,将被视为不能被使用.

  5. clipboard.js实现复制功能

    项目地址:https://github.com/zenorocha/clipboard.js 现代化的“复制到剪切板”插件.不包含 Flash.gzip 压缩后仅 3kb. 为什么使用它 复制文字到剪 ...

  6. 项目托管到Github上

    一.注册github账号   首先需要注册一个github账号,注册地址:https://github.com 接着会来到这 然后会收到一封github发的邮件,进入邮箱验证 二.创建个人的githu ...

  7. Session和Cookie的区别与联系

    一. 概念理解 你可能有留意到当你浏览网页时,会有一些推送消息,大多数是你最近留意过的同类东西,比如你想买桌子,上淘宝搜了一下,结果连着几天会有各种各样的桌子的链接.这是因为 你浏览某个网页的时候,W ...

  8. PHP中文件操作(1)--打开/读取文件

    1.打开文件(fopen) 语法:resource  $fp=fopen(文件地址,模式),返回的是文件指针(file pointer) 模式 含义 r 只读 w 写(清空重写) a 追加 $fp = ...

  9. 使用JavaScript动态更改CSS样式

    在很多情况下,都需要对网页上元素的样式进行动态的修改.在JavaScript中提供几种方式动态的修改样式,下面将介绍方法的使用.效果.以及缺陷. 1.使用obj.className来修改样式表的类名. ...

  10. charles 抓包 https 证书

    1. 概述 环境:这里是windows8 和 android (参考了ios环境的博客) 手机app点击发出http及https的请求,之前抓包都有请求的相关内容展示,这次没有,原来之前的一直抓的是h ...