码迷,mamicode.com
首页 > 其他好文 > 详细

2017.10.1解题报告

时间:2017-10-02 18:21:34      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:space   字符   reg   报告   blog   opened   gis   sizeof   mem   


 

预计分数: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 }
60分暴力
技术分享
 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 }
AC

 

T2

2017.10.1解题报告

标签:space   字符   reg   报告   blog   opened   gis   sizeof   mem   

原文地址:http://www.cnblogs.com/zwfymqz/p/7620489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!