NOIp 11.11/12
最后一场比较正式的NOIp模拟赛,写一发小总结。题目没什么好说的,大部分很简单,先贴一下代码。
1111 T1
//string
//by Cydiater
//2016.11.11
#include <iostream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <map>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <set>
#include <string>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define FILE "string"
const int MAXN=2e5+5;
const int oo=0x3f3f3f3f;
char q[MAXN];
int head,tail;
namespace solution{
void slove(){
char ch;head=1;tail=0;
while(scanf("%c",&ch)!=EOF){
bool flag=1;
while(tail>=head&&ch==q[tail]){tail--;flag=0;}
if(flag)q[++tail]=ch;
}
up(i,head,tail)if(q[i]!='\n'&&q[i]!='\r')printf("%c",q[i]);
puts("");
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
slove();
return 0;
}
1111 T2
//plus
//by Cydiater
//2016.11.11
#include <iostream>
#include <iomanip>
#include <queue>
#include <map>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define FILE "plus"
const int MAXN=1e6+5;
const int oo=0x3f3f3f3f;
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int Z,ans[MAXN],flag=-1,len=oo,test[MAXN],t[MAXN],top=0,head,tol;
namespace solution{//1 X first 0 Y first -1 none
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
void init(){
Z=read();
}
void updata(int x,int y){
top=0;
while(x!=1&&y!=1){
if(x>y){
head=1;t[++top]=x/y;
x%=y;
}else{
head=0;t[++top]=y/x;
y%=x;
}
}
if(x==1&&y>1){t[++top]=y-x;head=0;}
else if(y==1&&x>1){t[++top]=x-y;head=1;}
if(head==0&&flag==1)return;
if(flag==-1||(head==1&&flag==0)){
flag=head;tol=top;
up(i,1,top)ans[i]=t[i];
}else{
int now=1,opt=flag;
up(i,0,top-1){
if((t[top-i]>ans[tol-i]&&opt==1)||(t[top-i]<ans[tol-i]&&opt==0)){
flag=head;tol=top;
up(i,1,top)ans[i]=t[i];
return;
}else if((t[top-i]<ans[tol-i]&&opt==1)||(t[top-i]>ans[tol-i]&&opt==0))return;
opt^=1;
}
}
}
int get(int x,int y){
int tmp=0;
if(x<y)swap(x,y);
while(y!=0){
tmp+=x/y;
x%=y;
if(x<y)swap(x,y);
}
return tmp;
}
void slove(){
memset(test,10,sizeof(test));
up(i,1,Z)if(gcd(i,Z)==1)cmin(len,(test[i]=get(Z,i)-1));
up(i,1,Z)if(test[i]==len)updata(Z,i);
}
void output(){
down(i,tol,1){
up(j,1,ans[i])
if(flag) printf("X");
else printf("Y");
flag^=1;
}
puts("");
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
init();
slove();
output();
return 0;
}
1111 T3(80分,100分太毒瘤不改了)
//aiur
//by Cydiater
//2016.11.11
#include <iostream>
#include <queue>
#include <map>
#include <ctime>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
#include <string>
#include <bitset>
#include <set>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define FILE "aiur"
const int MAXN=2e6+5;
const int oo=0x3f3f3f3f;
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int N,ty;
ll ans=0,f[MAXN];
struct XY{int x,y;}xy[MAXN];
priority_queue<int,vector<int>,greater<int> >num1,num2;//small
priority_queue<int>num3,num4;//big
namespace solution1{
/*
f[i]=f[i-1]+abs(xi-xj)+abs(yi-yj)
f[i]=f[i-1]+max(xi-xj,xj-xi)+max(yi-yj,yj-yi)
////////////////////////////////////////////
f[i]=f[i-1]+(xi+yi)-(xj+yj) (1)
f[i]=f[i-1]+(xi-yi)-(xj-yj) (2)
f[i]=f[i-1]-(xi-yi)+(xj-yj) (3)
f[i]=f[i-1]-(xi+yi)+(xj+yj) (4)
sort by -(xj+yj) -(xj-yj) (xj-yj) (xj+yj)
slove me in O(NlogN) 40 part
*/
void init(){
up(i,1,N){
int x=read(),y=read();
xy[i]=(XY){x,y};
}
}
void push(int id){
int sum=xy[id].x+xy[id].y,delta=xy[id].x-xy[id].y;
num1.push(sum);num2.push(delta);
num3.push(delta);num4.push(sum);
}
void slove(){
push(1);
up(i,2,N){
ll tmp=0,n1=num1.top(),n2=num2.top(),n3=num3.top(),n4=num4.top(),x=xy[i].x,y=xy[i].y;
tmp=max(x+y-n1,max(x-y-n2,max(y-x+n3,n4-x-y)));
ans+=tmp;
push(i);
}
cout<<ans<<endl;
}
}
namespace solution2{
void init(){
up(i,0,N-1){
int x=read(),y=read();
xy[i]=(XY){x,y};
}
}
int get(int sta,int id){
int tmp=0;
up(i,0,N-1)if(((1<<i)&sta)==(1<<i))cmax(tmp,abs(xy[id].x-xy[i].x)+abs(xy[id].y-xy[i].y));
return tmp;
}
void slove(){
memset(f,10,sizeof(f));
f[0]=0;
up(i,1,(1<<N)-1){
up(j,0,N-1)if((i&(1<<j))){
int sta=i^(1<<j);
cmin(f[i],f[sta]+get(sta,j));
}
}
cout<<f[(1<<N)-1]<<endl;
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
N=read();ty=read();
if(ty==1){
using namespace solution1;
init();
slove();
}else {
using namespace solution2;
init();
slove();
}
return 0;
}
1112 T1
//array
//by Cydiater
//2016.11.12
#include <iostream>
#include <iomanip>
#include <queue>
#include <map>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <set>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define Auto(i,node) for(int i=LINK[node];i;i=e[i].next)
#define FILE "array"
const int MAXN=1e5+5;
const int oo=0x3f3f3f3f;
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int N,LINK[MAXN],len=0,lable[MAXN],id[MAXN],num,node=0,cnt=0,fa[MAXN];
struct edge{
int y,next;
}e[MAXN<<1];
char opt[5];
namespace solution{
inline void insert(int x,int y){e[++len].next=LINK[x];LINK[x]=len;e[len].y=y;}
void slove(){
N=read();
memset(fa,0,sizeof(fa));
memset(LINK,0,sizeof(LINK));
memset(lable,0,sizeof(lable));
lable[0]=-1;
up(j,1,N){
scanf("%s",opt+1);
id[j]=node;
if(opt[1]=='a'){
num=read();bool flag=1;
Auto(i,node)if(lable[e[i].y]==num){
flag=0;node=e[i].y;
}
if(flag){
insert(node,++cnt);
lable[cnt]=num;
fa[cnt]=node;node=cnt;
}
}else if(opt[1]=='s')node=fa[node];
else{
num=read();
node=id[num];
}
printf("%d\n",lable[node]);
}
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
slove();
return 0;
}
1112 T2
//blossom
//by Cydiater
//2016.11.12
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <set>
using namespace std;
#define ll long long
#define up(i,j,n) for(ll i=j;i<=n;i++)
#define down(i,j,n) for(ll i=j;i>=n;i--)
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define FILE "blossom"
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
ll N,M,lim1,lim2,ans=0;
namespace solution{
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
void init(){
N=read();M=read();lim1=read();lim2=read();
}
void slove(){
if(lim1<=1)ans+=(N*(M+1)+(N+1)*M);
up(i,1,N)up(j,1,M)if(gcd(i,j)==1){
if(i*i+j*j>=lim1*lim1&&i*i+j*j<=lim2*lim2)ans+=(N-i+1)*(M-j+1)*2;
}
cout<<ans<<endl;
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
init();
slove();
return 0;
}
1112 T3
//chen
//by Cydiater
//2016.11.12
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <cmath>
#include <ctime>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define FILE "chen"
const int MAXN=1e6+5;
const int oo=0x3f3f3f3f;
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
ll N,num[MAXN],a[MAXN],pos,L,R,v,K[MAXN],top=0,Num[MAXN];
ll Y=0;
struct tree{
int delta,v,maxx;
}t[MAXN<<2];
namespace solution{
inline void downit(int root){
int delta=t[root].delta;t[root].delta=0;
if(delta==0) return;
t[root<<1].delta+=delta;t[root<<1|1].delta+=delta;
t[root<<1].v+=delta;t[root<<1|1].v+=delta;
t[root<<1].maxx+=delta;t[root<<1|1].maxx+=delta;
}
inline void reload(int root){
t[root].v=min(t[root<<1].v,t[root<<1|1].v);
t[root].maxx=max(t[root<<1].maxx,t[root<<1|1].maxx);
}
inline int Get(int x){
int leftt=1,rightt=top,mid;
while(leftt+1<rightt){
mid=(leftt+rightt)>>1;
if(num[mid]>x) rightt=mid;
else leftt=mid;
}
if(num[leftt]==x)return leftt;
return rightt;
}
void init(){
N=read();
up(i,1,N)num[i]=a[i]=read();
sort(num+1,num+N+1);
up(i,1,N)if(num[i]!=num[i-1])Num[++top]=num[i];
memcpy(num,Num,sizeof(num));
up(i,1,N)a[i]=Get(a[i]);
}
int get(int leftt,int rightt,int root){
if(leftt!=rightt)downit(root);
if(t[root].maxx==0) return leftt;
if(t[root].v==0&&leftt==rightt) return leftt;
if(t[root].v>0) return oo;
int mid=(leftt+rightt)>>1;
return min(get(leftt,mid,root<<1),get(mid+1,rightt,root<<1|1));
}
void updata(int leftt,int rightt,int root){
if(leftt!=rightt)downit(root);
if(leftt>R||rightt<L) return;
if(leftt>=L&&rightt<=R){
t[root].delta+=v;
t[root].v+=v;
t[root].maxx+=v;
return;
}
int mid=(leftt+rightt)>>1;
updata(leftt,mid,root<<1);
updata(mid+1,rightt,root<<1|1);
reload(root);
}
void res(int leftt,int rightt,int root){
if(leftt==rightt){
K[leftt]=t[root].v;
return;
}
downit(root);
int mid=(leftt+rightt)>>1;
res(leftt,mid,root<<1);
res(mid+1,rightt,root<<1|1);
reload(root);
}
void slove(){
up(i,1,N){
pos=get(1,N,1);
L=1;R=a[i];v=1;
updata(1,N,1);
if(a[i]+1<=pos-1){
L=a[i]+1;R=pos-1;v=-1;
updata(1,N,1);
}
Y+=num[a[i]];
}
pos=get(1,N,1);
res(1,N,1);
up(i,1,pos)Y-=K[i]*(num[i]-num[i-1]);
cout<<Y<<endl;
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
init();
slove();
return 0;
}
这次两场发挥都比较稳定,没有什么严重的失误。也是现在意识到了对拍真的很强大。以往的观念里可能只是T3需要拍一拍,T1和T2不需要拍。这两场的T1和T2都选择先写暴力再搞正解,然后扔那里拍再去搞下一题。其实拍T1的意义并不大,但是拍了后心态就会稳很多,能明白自己多少分是已经稳了。搞下一题的时候心态也就不会那么慌。
高一的时候NOIp和省选都挂的很惨,每次都是抱憾而归。闵神讲他高一过度注重理论而轻实践导致高一走了弯路。我觉得我是过度重实践了,一定层次的竞赛考的一定不是你敲过什么。不停的学新东西固然没什么错,稳扎稳打的结果可能也没有那么出彩,但是这就是最后一次机会了,稳了两天的前两题,就是成功。
NOIp 11.11/12的更多相关文章
- [团队项目]第二个冲刺 看板和燃尽图 Sprint2 6.8/6.9/6.10/6.11/6.12/6.13/6.14
1.开始一个新的冲刺: 起止:2016.6.1~2016.6.14 按照以下过程进行 ProductBacklog:继续向下细化 Sprint 计划会议:确定此次冲刺要完成的目标 Sprint Bac ...
- 2016年11月12日 星期六 --出埃及记 Exodus 20:3
2016年11月12日 星期六 --出埃及记 Exodus 20:3 "You shall have no other gods before me.除了我以外,你不可有别的 神.
- Atitit jquery 1.4--v1.11 v1.12 v2.0 3.0 的新特性
Atitit jquery 1.4--v1.11 v1.12 v2.0 3.0 的新特性 1.1. Jquery1.12 jQuery 2.2 和 1.12 新版本发布 - OPEN资讯.h ...
- TeamWork#3,Week5,Scrum Meeting 11.6, 11.7, 11.11, 11.12
11.6:到目前为止基本已完成相关知识的学习,各方面工作都开始进行,一开始进行比较慢. 11.7:项目遇到困难,需要补充相关知识,进度慢了下来. 11.11:各方面工作进展比较顺利,没有什么大问题. ...
- 阅读<构建之法>第三10、11、12章并提出问题
<构建之法>第10.11.12章 第10章: 问题:对我们了解了用户的需求后,但是我们想法和做出来的软件会和用户的需求有偏差,比如风格.界面的修饰等等,那么我们程序猿怎样才能让自己的想法更 ...
- MAC 下编译 ANDROID P 源码 提示 internal error: Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13"]
MAC 下编译 ANDROID P 源码出现下面的问题: ninja: no work to do. [21/21] out/soong/.bootstrap/bin/soong_build out/ ...
- JDBC中 mysql数据库的连接工具类 Java登录 及增删改查 整理 附带:Navicat Premium 11.0.12中文破解版.zip(下载)mysql数据库工具
先写一个工具类,有实现MySQL数据库连接的方法,和关闭数据库连接.关闭ResultSet 结果集.关闭PreparedStatement 的方法.代码如下: package com.swift; ...
- 总结近期CNN模型的发展(一)---- ResNet [1, 2] Wide ResNet [3] ResNeXt [4] DenseNet [5] DPNet [9] NASNet [10] SENet [11] Capsules [12]
总结近期CNN模型的发展(一) from:https://zhuanlan.zhihu.com/p/30746099 余俊 计算机视觉及深度学习 1.前言 好久没有更新专栏了,最近因为项目的原因接 ...
- 8.1 NOIP模拟11
8.1 NOIP模拟 11 今天上午返校之后,颓了一会,然后下午就开始考试,中午睡着了,然后刚开始考试的时候就困的一匹,我一看T1,woc,这不是之前线段树专题的题啊,和那道题差不多,所以我..... ...
随机推荐
- dialog 模块化窗口
xDialog 方法 说明 参数 modal(opts) 模块化弹窗 opts={ title:'标题' , width : '宽度(400)', height : '高度(300)', button ...
- SharePoint 2010 数据库xxx的事务日志已满
接到领导安排,说客户有问题 请求协助解决,对方给我展示的错误日志,如下: 数据库'WSS_Content_xxxx'的事务日志已满.若要查明无法重用日志中的空间的原因,请参阅sy.databases中 ...
- React Native FlexBox
FlexBox 是React Native布局的一种算法,目的是为了适配不同尺寸的屏幕而设计的. 使用时最关键的就是flex关键字的用法. flex用于修饰当前View在父视图中的占比. 占比如何计算 ...
- android Activity runOnUiThread() 方法的使用
利用Activity.runOnUiThread(Runnable)把更新ui的代码创建在Runnable中,然后在需要更新ui时,把这个Runnable对象传给Activity.runOnUiThr ...
- iOS项目分析及优化
iOS项目分析及优化 来源:吴白的简书 从代码看一个程序员的笔力 从代码的整洁度上就可以看出一个程序员的实力,规范其实就是让你养成一种良好习惯的标杆,在此面前我们应该顺从.本篇我们以OC为例,统 ...
- hexo+next博客添加搜索
1.为什么添加algolia搜索 第一当然是可以方便的查找所需文章,第二点就是之前常用的swiftype插件不再免费.我的个人博客是这个月初搭建完成的,这时候swiftype已经不再免费,而且只开放企 ...
- jquery ajax异步和同步从后天取值
最近使用jquery的ajax,发现有些效果不对,ajax请求后返回的json串回来了,但是执行顺序有问题. var isReload = false; $.post('/home/DetectCac ...
- C# 模板列在绑定的时候取文本值
查了很多资料,都说模板列无法取文本值, 需要使用FindControl, 对于列数很多的情况就要命了, 使用以下方式, 可以循环列的索引,获取到文本值 前台 <asp:TemplateField ...
- TNS-12535: TNS:operation timed out案例解析
一数据库突然连接不上,在自己电脑上使用SQL Developer也连接不上.立即使用SecureCRT连接上了这台服务器,从下面几个方面检查. 1:检查了数据库的状态是否正常 $ sqlplus / ...
- QString::arg的用法
1.用法示例1 String str = QString("%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11").arg("1"," ...