标签:open math else lag 就会 lin its string 心态
最后一场比较正式的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和省选都挂的很惨,每次都是抱憾而归。闵神讲他高一过度注重理论而轻实践导致高一走了弯路。我觉得我是过度重实践了,一定层次的竞赛考的一定不是你敲过什么。不停的学新东西固然没什么错,稳扎稳打的结果可能也没有那么出彩,但是这就是最后一次机会了,稳了两天的前两题,就是成功。
标签:open math else lag 就会 lin its string 心态
原文地址:http://www.cnblogs.com/Cydiater/p/6058446.html