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,这不是之前线段树专题的题啊,和那道题差不多,所以我..... ...
随机推荐
- 深入理解javascript闭包(二)
在上次的分享中javascript--函数参数与闭包--详解,对闭包的解释不够深入.本人经过一段时间的学习,对闭包的概念又有了新的理解.于是便把学习的过程整理成文章,一是为了加深自己闭包的理解,二是给 ...
- VS2012 Unit Test——Microsoft Fakes入门
如题,本文主要作为在VS2012使用Fakes的入门示例,开发工具必须是VS2012或更高版本. 关于Fakes的MSDN地址:http://msdn.microsoft.com/en-us/libr ...
- UITextField
UITextFieldDemo 效果 特点 1.有效定制键盘的样式 2.处理键盘对文本框的遮挡 用法 1.导入文件(UITextField+CreateInputAccessoryView.h/.m) ...
- [Modern OpenGL系列(二)]创建OpenGL窗口
本文已同步发表在CSDN:http://blog.csdn.net/wenxin2011/article/details/51295663 在博主的上一篇文章中已经介绍了OpenGL开发环境的搭建,本 ...
- IntelliJ IDEA安装及jsp开发环境搭建
一.前言 现在.net国内市场不怎么好,公司整个.net组技术转型,就个人来说还是更喜欢.net,毕竟不是什么公司都像微软一样财大气粗开发出VS这样的宇宙级IDE供开发者使用,双击sln即可打开项目, ...
- mount常用挂载命令
挂接命令(mount) 首先,介绍一下挂接(mount)命令的使用方法,mount命令参数非常多,这里主要讲一下今天我们要用到的. 命令格式: mount [-t vfstype] [-o optio ...
- apache 开机自启动脚本设置
默认我们源码编译安装apache,是不能使用service这个命令来启动的,通常我们启动的命令是: [root@localhost httpd-2.2.16]# /usr/local/apache2/ ...
- [转]An introduction to OAuth 2.0 using Facebook in ASP.NET Core
本文转自:http://andrewlock.net/an-introduction-to-oauth-2-using-facebook-in-asp-net-core/ This is the ne ...
- 在Ubuntu Server 14.04中搭建FTP服务器(VMWare)
自己搭建ftp服务器,方便主机与虚拟机中的Ubuntu传输文件. 选用的ftp软件为vsftpd. 1.命令行: sudo apt-get install vsftpd 2.安装完配置: vsftpd ...
- 2016年Web前端面试题目
以下是收集一些面试中经常会遇到的经典面试题以及自己面试过程中无法解决的问题,通过对知识的整理以及经验的总结,重新巩固自身的前端基础知识,如有错误或更好的答案,欢迎指正.:) HTML/CSS部分 1. ...