清北刷题冲刺 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 ...
随机推荐
- poj 3666 Making the Grade(dp离散化)
Making the Grade Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7068 Accepted: 3265 ...
- 验证reg注册表的操作
// wRegKeyclass wRegKey{ // Operationspublic: BOOL Create(HKEY hKeyParent, LPCTSTR lpszKeyName , LPT ...
- php-fpm进程内存泄漏
线上服务器内存报警 线上web8G内存的服务器,内存几乎吃光,top查看,发现php-fpm进程每个都是几十M,php-fpm配置static, 一共150个 解决 排除过程中,其他机器相同配置都没有 ...
- FEC之我见四
接上文,来详细的说明一下FEC前向纠错的具体实现: FEC_matrix是一个比较常用的算法,Vandermonde,范德蒙矩阵是法国数学家范德蒙提出的一种各列为几何级数的矩阵. 范德蒙矩阵的定义: ...
- BZOJ4676 Xor-Mul棋盘
传送门 题目大意懒得写了,题目说的挺明白的了 题解 主要的难点在于异或意义下的最大值和很玄学,但不难发现这道题中让你定义的$D_{i,j}$只参与异或运算,所以我们可以逐位进行讨论.所以我们每一位就只 ...
- [基本操作]线段树分治和动态dp
不知道为什么要把这两个没什么关系的算法放到一起写...可能是都很黑科技? 1.线段树分治 例题:bzoj4026 二分图 给你一个图,资瓷加一条边,删一条边,询问当前图是不是二分图 如果用 LCT 的 ...
- Asp.Net页面生命周期【转载,地址:http://www.cnblogs.com/xhwy/archive/2012/05/20/2510178.html】
一.什么是Asp.Net页面生命周期 当我们在浏览器地址栏中输入网址,回车查看页面时,这时会向服务器端(IIS)发送一个request请求,服务器就会判断发送过来的请求页面, 完全识别 HTTP 页 ...
- [转]关于新一轮QQ Tencent://Message 在线联系
关于在线QQ代码. 以前的QQ代码都需要添加好友. 现在的 首先是到http://wp.qq.com/生成你的QQ在线代码 很长的一段代码,并且每个QQ生成的sigT字符串都是不一样的.. 闲来无事, ...
- 【转】Pro Android学习笔记(二三):用户界面和控制(11):其他控件
目录(?)[-] Chronometer计时器控件 倒计时CountDownTimer Switch控件 Space控件 其他控件 Android提供了很多控件,基本上都是view的扩展. Chron ...
- unittest 执行测试脚本输出测试报告
import unittestimport HTMLTestRunnertest as HTMLTestRunner#获取路径path = './'#创建测试套件,读取测试脚本suite = unit ...