Educational Codeforces Round 26 A—C

来源:互联网 发布:吃鸡买号还是软件 编辑:程序博客网 时间:2024/06/05 08:11

传送门:点击打开链接

A. Text Volume
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a text of single-space separated words, consisting of small and capital Latin letters.

Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.

Calculate the volume of the given text.

Input

The first line contains one integer number n (1 ≤ n ≤ 200) — length of the text.

The second line contains text of single-space separated words s1, s2, ..., si, consisting only of small and capital Latin letters.

Output

Print one integer number — volume of text.

Examples
input
7NonZERO
output
5
input
24this is zero answer text
output
0
input
24Harbour Space University
output
1
Note

In the first example there is only one word, there are 5 capital letters in it.

In the second example all of the words contain 0 capital letters.

题意是给定一串字符串,求出每个单词中最多有几个大写字母。

代码实现:

#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int main(){char map[205];int i,n,ans,maxn;while(cin>>n){memset(map,'\0',sizeof(map));for(i=0;i<=n;i++)scanf("%c",&map[i]);ans=0;maxn=0;getchar();for(i=0;i<=n;i++){if(map[i]>='A'&&map[i]<='Z'){ans++;}if(map[i]==' ')ans=0;maxn=max(maxn,ans);}cout<<maxn<<endl;}return 0;}

B. Flag of Berland
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The flag of Berland is such rectangular field n × m that satisfies following conditions:

  • Flag consists of three colors which correspond to letters 'R''G' and 'B'.
  • Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
  • Each color should be used in exactly one stripe.

You are given a field n × m, consisting of characters 'R''G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).

Input

The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.

Each of the following n lines consisting of m characters 'R''G' and 'B' — the description of the field.

Output

Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).

Examples
input
6 5RRRRRRRRRRBBBBBBBBBBGGGGGGGGGG
output
YES
input
4 3BRGBRGBRGBRG
output
YES
input
6 7RRRGGGGRRRGGGGRRRGGGGRRRBBBBRRRBBBBRRRBBBB
output
NO
input
4 4RRRRRRRRBBBBGGGG
output
NO
Note

The field in the third example doesn't have three parralel stripes.

Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 21 and 1.


题意给定一个n*m矩阵,矩阵能不能分成3个面积相等的小矩阵。

模拟。

代码实现:

#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;char map[105][105];int main(){int m,n,i,j,k,ans1,ans2,ans3;while(cin>>n>>m){getchar();for(i=0;i<n;i++){scanf("%s",map[i]);}ans1=ans2=ans3=0;for(i=0;i<n;i++){char ch=map[i][0];for(j=1;j<m;j++){if(map[i][j]!=ch)break;}if(map[i][0]=='R'&&j==m)ans1++;if(map[i][0]=='B'&&j==m)ans2++;if(map[i][0]=='G'&&j==m)ans3++;}if(ans1==ans2&&ans2==ans3&&(ans1&&ans2&&ans3)){int flag=1;if(n==2)cout<<"YES"<<endl;else{for(i=0;i<n;i+=ans1){for(j=i+1;j<i+ans1;j++){if(map[i][0]!=map[j][0])flag=0;}}if(flag){cout<<"YES"<<endl;}}if(flag)continue;}ans1=ans2=ans3=0;for(i=0;i<m;i++){char ch=map[0][i];for(j=1;j<n;j++){if(map[j][i]!=ch)break;}if(map[0][i]=='R'&&j==n)ans1++;if(map[0][i]=='B'&&j==n)ans2++;if(map[0][i]=='G'&&j==n)ans3++;}if(ans1==ans2&&ans2==ans3&&(ans1&&ans2&&ans3)){int flag=1;if(m==2)cout<<"YES"<<endl;else{for(i=0;i<m;i+=ans1)for(j=i+1;j<i+ans1;j++)if(map[0][i]!=map[0][j])flag=0;if(flag)cout<<"YES"<<endl;}}elsecout<<"NO"<<endl;}return 0;}


C. Two Seals
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One very important person has a piece of paper in the form of a rectangle a × b.

Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi × yi. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees).

A very important person wants to choose two different seals and put them two impressions. Each of the selected seals puts exactly one impression. Impressions should not overlap (but they can touch sides), and the total area occupied by them should be the largest possible. What is the largest area that can be occupied by two seals?

Input

The first line contains three integer numbers na and b (1 ≤ n, a, b ≤ 100).

Each of the next n lines contain two numbers xiyi (1 ≤ xi, yi ≤ 100).

Output

Print the largest total area that can be occupied by two seals. If you can not select two seals, print 0.

Examples
input
2 2 21 22 1
output
4
input
4 10 92 31 15 109 11
output
56
input
3 10 106 67 720 5
output
0
Note

In the first example you can rotate the second seal by 90 degrees. Then put impression of it right under the impression of the first seal. This will occupy all the piece of paper.

In the second example you can't choose the last seal because it doesn't fit. By choosing the first and the third seals you occupy the largest area.

In the third example there is no such pair of seals that they both can fit on a piece of paper.


给你一个固定面积,向里面贴两张海报,问这两张海报面积最大 为多少。

模拟。

代码实现:

#include<iostream>#include<algorithm>#include<cstring>using namespace std;int n,x,y,maxn;int map[105][2];bool judge(int a,int b,int c,int d){if(a<=c&&b<=d)return true;swap(a,b);if(a<=c&&b<=d)return true;elsereturn false;}int main(){int i,j,k;while(cin>>n>>x>>y){for(i=0;i<n;i++)cin>>map[i][0]>>map[i][1];maxn=0;for(i=0;i<n;i++){for(j=i+1;j<n;j++){for(k=1;k<x;k++){if(judge(map[i][0],map[i][1],k,y)&&judge(map[j][0],map[j][1],x-k,y))break;}if(k<x)maxn=max(maxn,map[i][0]*map[i][1]+map[j][0]*map[j][1]);for(k=1;k<y;k++){if(judge(map[i][0],map[i][1],x,k)&&judge(map[j][0],map[j][1],x,y-k))break;}if(k<y)maxn=max(maxn,map[i][0]*map[i][1]+map[j][0]*map[j][1]);}}cout<<maxn<<endl; }return 0;}



原创粉丝点击