清北刷题冲刺 10-30 a.m
星空

#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
int main(){
freopen("star.in","r",stdin);freopen("star.out","w",stdout);
while(){
scanf("%d%d",&n,&m);
if(n==&&m==)return ;
if((n*m)%==)puts("Yuri");
else puts("Chito");
}
}
100分 规律
战争

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define maxn 50010
#define mod 1000000007
using namespace std;
int n,k,a[maxn],mx;
vector<int>b;
long long ans;
bool cmp(int x,int y){return x>y;}
int main(){
freopen("war.in","r",stdin);freopen("war.out","w",stdout);
// freopen("Cola.txt","r",stdin);
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++)scanf("%d",&a[i]);
for(int i=;i<=n;i++)
for(int j=i+;j<=n;j++){
int w=a[i]^a[j];
b.push_back(w);
}
sort(b.begin(),b.end(),cmp);
for(int i=;i<k;i++){
ans+=b[i];
while(ans>=mod)ans-=mod;
}
cout<<ans;
}
40分 枚举
无题


#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 100010
using namespace std;
int n,m,a[maxn],b[maxn];
struct node{
int l,r,v,lazy;
}tr[*];
struct Nde{
int opt,x,y,z;
}qu[maxn];
bool flag=;
int opl,opr,opv;
bool cmp(int x,int y){return x>y;}
void build(int l,int r,int k){
tr[k].l=l;tr[k].r=r;
if(l==r){tr[k].v=a[l];return;}
int mid=(l+r)>>;
build(l,mid,k<<);
build(mid+,r,k<<|);
tr[k].v=max(tr[k<<].v,tr[k<<|].v);
}
void update(int k){
tr[k<<].lazy+=tr[k].lazy;
tr[k<<].v+=tr[k].lazy;
tr[k<<|].lazy+=tr[k].lazy;
tr[k<<|].v+=tr[k].lazy;
tr[k].lazy=;
}
int query(int l,int r,int k){
if(tr[k].l>=opl&&tr[k].r<=opr)return tr[k].v;
if(tr[k].lazy)update(k);
int mid=(l+r)>>;
int res=;
if(opl<=mid)res=max(res,query(l,mid,k<<));
if(opr>mid)res=max(res,query(mid+,r,k<<|));
tr[k].v=max(tr[k<<].v,tr[k<<|].v);
return res;
}
void change(int l,int r,int k){
if(tr[k].l>=opl&&tr[k].r<=opr){
tr[k].v+=opv;
tr[k].lazy+=opv;
return;
}
if(tr[k].lazy)update(k);
int mid=(l+r)>>;
if(opl<=mid)change(l,mid,k<<);
if(opr>mid)change(mid+,r,k<<|);
tr[k].v=max(tr[k<<].v,tr[k<<|].v);
}
int main(){
freopen("noname.in","r",stdin);freopen("noname.out","w",stdout);
// freopen("Cola.txt","r",stdin);
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)scanf("%d",&a[i]);
for(int i=;i<=m;i++){
scanf("%d%d%d%d",&qu[i].opt,&qu[i].x,&qu[i].y,&qu[i].z);
if(qu[i].opt==&&qu[i].z!=)flag=;
}
if(flag){
build(,n,);
for(int i=;i<=m;i++){
opl=qu[i].x;opr=qu[i].y;
if(qu[i].opt==){
if(qu[i].z>qu[i].y-qu[i].x+)puts("-1");
else printf("%d\n",query(,n,));
}
else {
opv=qu[i].z;
change(,n,);
}
}
}
else{
for(int i=;i<=m;i++){
if(qu[i].opt==)
for(int j=qu[i].x;j<=qu[i].y;j++)a[j]+=qu[i].z;
if(qu[i].opt==){
int cnt=;
for(int j=qu[i].x;j<=qu[i].y;j++)b[++cnt]=a[j];
sort(b+,b+cnt+,cmp);
if(cnt<qu[i].z)puts("-1");
else printf("%d\n",b[qu[i].z]);
}
}
}
}
50分 枚举+线段树
/*
k<=10,所以维护区间前10大,用左右子树的前10大更新根节点的前10大
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 100010
#define maxk 10
using namespace std;
int n,m,col[maxn<<|],opl,opr,opv;
struct rec{
int res[maxk];
rec operator + (const rec &b)const{
rec z;
int p1=,p2=;
for(int i=;i<maxk;i++){
if(res[p1]>b.res[p2])z.res[i]=res[p1++];
else z.res[i]=b.res[p2++];
}
return z;
}
}z[maxn<<|];
void color(int k,int c){
col[k]+=c;
for(int i=;i<maxk;i++)
if(z[k].res[i])z[k].res[i]+=c;
}
void push_col(int k){
if(col[k]){
color(k<<,col[k]);
color(k<<|,col[k]);
col[k]=;
}
}
void update(int k){
z[k]=z[k<<]+z[k<<|];
}
void build(int l,int r,int k){
if(l==r){
scanf("%d",&z[k].res[]);
return;
}
int mid=(l+r)>>;
build(l,mid,k<<);
build(mid+,r,k<<|);
update(k);
}
rec query(int l,int r,int k){
if(opl<=l&&opr>=r)return z[k];
push_col(k);
int mid=(l+r)>>;
/*if(opr<=mid)return query(l,mid,k<<1);
else if(opl>mid)return query(mid+1,r,k<<1|1);
else return query(l,mid,k<<1)+query(mid+1,r,k<<1|1);*/
if (opl<=mid)
{
if (mid<opr) return query(l,mid,k<<)+query(mid+,r,k<<|);
else return query(l,mid,k<<);
}
else return query(mid+,r,k<<|);
}
void modify(int l,int r,int k){
if(opl<=l&&opr>=r){
color(k,opv);
return;
}
push_col(k);
int mid=(l+r)>>;
if(opl<=mid)modify(l,mid,k<<);
if(opr>mid)modify(mid+,r,k<<|);
update(k);
}
int main(){
freopen("noname.in","r",stdin);freopen("noname.out","w",stdout);
// freopen("Cola.txt","r",stdin);
scanf("%d%d",&n,&m);
build(,n,);
for(int i=;i<=m;i++){
int opt;
scanf("%d%d%d%d",&opt,&opl,&opr,&opv);
if(opt==){
if(opr-opl+<opv)puts("-1");
else printf("%d\n",query(,n,).res[opv-]);
}
else modify(,n,);
}
return ;
}
100分 线段树
预计得分0++
实际得分100++
T1看起来应该是个结论题,我博弈论很弱所以就找了半个小时规律,就写出来了,但是不会证明。T2不会正解,就直接枚举了,但是非常不小心的是在排序之前取了模,所以排序有误,报零了。T3没看到输出-1的情况,少了30分,很可惜
今天上午精神状态不好,发挥不佳,有很多细节出了错误,导致成绩与预计得分差距较大,以后要认真审题,谨慎写代码,考场上调整好状态
小结
清北刷题冲刺 10-30 a.m的更多相关文章
- 清北刷题冲刺 10-28 p.m
水题(贪心) (water) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK出了道水题. 这个水题是这样的:有两副牌,每副牌都有n张. 对于第一副牌的每 ...
- 2017-10-4 清北刷题冲刺班p.m
P102zhx a [问题描述]你是能看到第一题的 friends 呢.——hja两种操作:1.加入一个数.2.询问有多少个数是?的倍数.[输入格式]第一行一个整数?,代表操作数量.接下来?行,每行两 ...
- 2017-10-4 清北刷题冲刺班a.m
P101zhx a [问题描述]你是能看到第一题的 friends 呢.——hjaHja 拥有一套时光穿梭技术,能把字符串以超越光速的速度传播,但是唯一的问题是可能会 GG.在传输的过程中,可能有四种 ...
- 2017-10-3 清北刷题冲刺班a.m
P99zhx a [问题描述]你是能看到第一题的 friends 呢.——hja怎么快速记单词呢?也许把单词分类再记单词是个不错的选择.何大爷给出了一种分单词的方法,何大爷认为两个单词是同一类的当这两 ...
- 2017-10-2 清北刷题冲刺班a.m
一道图论神题 (god) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图,只 ...
- 2017-10-2 清北刷题冲刺班p.m
最大值 (max) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一本书,上面有很多有趣的OI问题.今天LYK看到了这么一道题目: 这里有一个长度为n ...
- 2017-10-1 清北刷题冲刺班p.m
一道图论好题 (graph) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图 ...
- 清北刷题冲刺 11-03 a.m
纸牌 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> ...
- 清北刷题冲刺 11-01 p.m
轮换 #include<iostream> #include<cstdio> #include<cstring> #define maxn 1010 using n ...
随机推荐
- C#中string.Empty、""和null 之间的区别
1.C#中string.Empty.""和null 之间的区别 (http://blog.csdn.net/henulwj/article/details/7830615)
- OpenCV——旋转模糊 (二)
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- ACM学习历程—HDU1030 Delta-wave(数学)
Description A triangle field is numbered with successive integers in the way shown on the picture be ...
- VC6++常用快捷键
VC6快捷键大全(转载) VC6快捷键大全,记在这里,方便查阅.F1: 帮助Ctrl+O :OpenCtrl+P :PrintCtrl+N :NewCtrl+Shift+F2 :清除所有书签F2 :上 ...
- http之pragma
关于Pragma:no-cache,跟Cache-Control: no-cache相同.Pragma: no-cache兼容http 1.0 ,Cache-Control: no-cache是htt ...
- 洛谷【P1358】扑克牌
我对状态空间的理解:https://www.cnblogs.com/AKMer/p/9622590.html 题目传送门:https://www.luogu.org/problemnew/show/P ...
- bzoj 4530 大融合 —— LCT维护子树信息
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4530 用LCT维护子树 size,就是实边和虚边分开维护: 看博客:https://blog ...
- 使用PowerShell创建Azure Storage的SAS Token访问Azure Blob文件
Azure的存储包含Storage Account.Container.Blob等具体的关系如下: 我们常用的blob存储,存放在Storage Account的Container里面. 目前有三种方 ...
- Azure 用户自定义路由 (User Defined Route)
在公有云环境中,用户创建了一个Vnet,添加了若干个网段后,这几个网段是全联通的状态. 如果希望在Vnet中添加一些功能性的设备,比如防火墙.IPS.负载均衡设备等,就需要进行用户自定义路由的配置. ...
- 【转】 Pro Android学习笔记(七十):HTTP服务(4):SOAP/JSON/XML、异常
目录(?)[-] SOAP JSON和XMLPullParser Exception处理 文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件,转载须注明出处:http://blog. ...