2017.9.23清北第二场
Posted 自为
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2017.9.23清北第二场相关的知识,希望对你有一定的参考价值。
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 const int MAXN=400001; 8 inline void read(int &n) 9 { 10 char c=getchar();n=0;bool flag=0; 11 while(c<‘0‘||c>‘9‘) c==‘-‘?flag=1,c=getchar():c=getchar(); 12 while(c>=‘0‘&&c<=‘9‘) n=n*10+c-48,c=getchar();flag==1?n=-n:n=n; 13 } 14 int n,m,bgx,bgy,k; 15 int s,x,z,y; 16 int flag=0; 17 int nowx=1,nowy=1; 18 int nowstep=0; 19 int pd() 20 { 21 if(flag==1) nowstep++; 22 if(nowx==bgx&&nowy==bgy) flag=1; 23 if(nowstep==k) printf("%d %d",nowy-1,nowx-1),exit(0); 24 } 25 int main() 26 { 27 freopen("calc.in","r",stdin); 28 freopen("calc.out","w",stdout); 29 read(n);read(m);read(bgx);read(bgy);read(k); 30 if(k==0) printf("%d %d",bgx,bgy),exit(0); 31 swap(bgx,bgy);bgx++;bgy++;swap(n,m); 32 33 s=1,x=n,z=1,y=m; 34 while(s<=n&&x>=1&&z<=m&&y>=1) 35 { 36 while(nowy<y) 37 nowy++,pd(); s++; 38 while(nowx<x) 39 nowx++,pd(); y--; 40 while(nowy>z) 41 nowy--,pd(); x--; 42 while(nowx>s) 43 nowx--,pd(); z++; 44 } 45 return 0; 46 }
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 const int MAXN=200001; 8 inline void read(int &n) 9 { 10 char c=getchar();n=0;bool flag=0; 11 while(c<‘0‘||c>‘9‘) c==‘-‘?flag=1,c=getchar():c=getchar(); 12 while(c>=‘0‘&&c<=‘9‘) n=n*10+c-48,c=getchar();flag==1?n=-n:n=n; 13 } 14 int T,n; 15 int ans[MAXN]; 16 int a[MAXN]; 17 int main() 18 { 19 freopen("sum.in","r",stdin); 20 freopen("sum.out","w",stdout); 21 read(T); 22 while(T--) 23 { 24 read(n); 25 for(int i=1;i<=n;i++) read(a[i]); 26 for(int i=1;i<=n;i++) 27 { 28 int nowmax=-0x7fff,nowmin=0x7fff; 29 for(int j=i;j<=n;j++) 30 nowmin=min(nowmin,a[j]), 31 nowmax=max(nowmax,a[j]), 32 ans[nowmax-nowmin]++; 33 } 34 for(int i=1;i<=n-1;i++) ans[i]+=ans[i-1]; 35 for(int i=0;i<=n-1;i++) 36 printf("%d\n",ans[i]); 37 } 38 return 0; 39 }
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 const int MAXN=400001; 8 const int mod=1000000007; 9 inline void read(int &n) 10 { 11 char c=getchar();n=0;bool flag=0; 12 while(c<‘0‘||c>‘9‘) c==‘-‘?flag=1,c=getchar():c=getchar(); 13 while(c>=‘0‘&&c<=‘9‘) n=n*10+c-48,c=getchar();flag==1?n=-n:n=n; 14 } 15 int T,n,m,k; 16 int vis[MAXN]; 17 int happen[MAXN]; 18 int ans=0; 19 void dfs(int now) 20 { 21 if(now==n+1) 22 {ans=(ans+1)%mod;return ;} 23 if(vis[now]) dfs(now+1); 24 for(int i=now-k;i<=now+k;i++) 25 { 26 if(!happen[i]&&i>=1&&i<=n) 27 { 28 happen[i]=1; 29 dfs(now+1); 30 happen[i]=0; 31 } 32 } 33 34 } 35 int main() 36 { 37 freopen("count.in","r",stdin); 38 freopen("count.out","w",stdout); 39 read(T); 40 while(T--) 41 { 42 ans=0; 43 read(n);read(m);read(k);bool flag=0; 44 if(k==0) 45 { 46 printf("1"); 47 continue; 48 } 49 for(int i=1;i<=m;i++) 50 { 51 int x,y;read(x);read(y); 52 vis[x]=1;happen[y]=1; 53 if(abs(y-x)>k) 54 { flag=1;break; } 55 } 56 if(!flag) dfs(1); 57 printf("%d\n",ans%mod); 58 } 59 return 0; 60 }
以上是关于2017.9.23清北第二场的主要内容,如果未能解决你的问题,请参考以下文章
《蓝桥杯真题》:2020年单片机省赛第二场(第十一届第二场)
《蓝桥杯真题》:2020年单片机省赛第二场(第十一届第二场)