2017.10.1解题报告
Posted 自为
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2017.10.1解题报告相关的知识,希望对你有一定的参考价值。
预计分数:60+50+0=110
实际分数:60+81+0=144
全场rank13?全校rank1?貌似题很难啊23333
T1:
https://www.luogu.org/problem/show?pid=T11834
一道比noipT2还难的题,考场上果断打60分暴力走人
正解:对于字符a进行猜想,假定是最多的,计算a-b的值最大的就好
后者可以用两个前缀和维护,代码实现的技巧比较多
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 using namespace std; 7 const int MAXN=1001; 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 string a; 15 int happen[MAXN]; 16 int happenmax[MAXN][MAXN]; 17 int happenmin[MAXN][MAXN]; 18 int ans=0; 19 int main() 20 { 21 //freopen("a.in","r",stdin); 22 //freopen("a.out","w",stdout); 23 int meiyong; 24 cin>>meiyong; 25 cin>>a; 26 for(int i=0;i<a.length();i++) 27 { 28 memset(happen,0,sizeof(happen)); 29 for(int j=i;j<a.length();j++) 30 { 31 int nowmax=0,nowmin=0x7fff; 32 happen[a[j]]++; 33 for(register int k=97;k<=122;k++) 34 { 35 if(happen[k]>nowmax) nowmax=happen[k]; 36 if(happen[k]<nowmin&&happen[k]) nowmin=happen[k]; 37 } 38 if(nowmax-nowmin>ans) ans=nowmax-nowmin; 39 } 40 } 41 printf("%d",ans); 42 return 0; 43 }
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 using namespace std; 7 const int MAXN=1001; 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 string a; 15 int happen[MAXN]; 16 int happenmax[MAXN][MAXN]; 17 int happenmin[MAXN][MAXN]; 18 int ans=0; 19 int main() 20 { 21 //freopen("a.in","r",stdin); 22 //freopen("a.out","w",stdout); 23 int meiyong; 24 cin>>meiyong; 25 cin>>a; 26 for(register int i=0;i<a.length();i++) 27 { 28 memset(happen,0,sizeof(happen)); 29 for(register int j=i;j<a.length();j++) 30 { 31 int nowmax=0,nowmin=0x7fff; 32 happen[a[j]]++; 33 for(register int k=97;k<=122;k++) 34 { 35 if(happen[k]>nowmax) nowmax=happen[k]; 36 if(happen[k]<nowmin&&happen[k]) nowmin=happen[k]; 37 } 38 if(nowmax-nowmin>ans) ans=nowmax-nowmin; 39 } 40 } 41 printf("%d",ans); 42 return 0; 43 }
T2
以上是关于2017.10.1解题报告的主要内容,如果未能解决你的问题,请参考以下文章