Educational Codeforces Round 26 A B C题
题目链接
A. Text Volume
题意:计算句子中,每个单词大写字母出现次数最多的那个的出现次数(混不混乱QAQ).
解题思路:注意getchar()就没啥了.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<ctype.h>
#include<algorithm>
using namespace std;
int main()
{
int n;
char str[];
cin>>n;
getchar();
for(int i=;i<n;i++) scanf("%c",&str[i]);
int max_len=,cnt=;
for(int i=;i<n;i++)
{
if(isalpha(str[i])>)
{
if(str[i]>='A'&&str[i]<='Z') cnt++;
}
else max_len=max(max_len,cnt),cnt=;
}
max_len=max(max_len,cnt),cnt=;
cout<<max_len<<endl;
return ;
}
B. Flag of Berland
题意:色光三原色,RGB,判断这三个字母是否都出现且围成的图案要完全一样(条纹).
解题思路:暴力模拟,扫扫扫,直接看代码吧.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char Map[][];
int n,m,x,y;
void solve(char ch)
{
int flag=;
x=y=;
for(int i=;i<n&&flag;i++)
{
for(int j=;j<m&&flag;j++)
{
if(Map[i][j]==ch)
{
flag=;
int ii=i+,jj=j+;
x++,y++;
while(Map[i][jj]==ch&&jj<m)
{
jj++; y++;
}
while(Map[ii][j]==ch&&ii<n)
{
ii++; x++;
}
for(int _i=i;_i<ii;_i++)
{
for(int _j=j;_j<jj;_j++)
if(Map[_i][_j]!=ch)
{
x=y=; return ;
}
}
}
}
}
}
int main()
{ cin>>n>>m;
for(int i=;i<n;i++) scanf("%s",Map[i]);
if( (n*m)%!= )
{
puts("NO"); return ;
}
int a=,b=,a1=,b1=,a2=,b2=;
solve('R');
a=x,b=y; solve('B');
a1=x,b1=y; solve('G');
a2=x,b2=y; if(a&&b&&a1&&b1&&a2&&b2&&a*b+a1*b1+a2*b2==n*m
&&a==a1&&a1==a2&&b==b1&&b1==b2)
puts("YES");
else puts("NO");
return ;
}
C. Two Seals
题意:在n*m纸上,盖两个印章,在不越界前提下要求总面积最大,印章可旋转着盖.
解题思路:双重for循环,直接暴力枚举,每次取一次max.
刚开始没注意到是盖两个,用背包写了半天,半路发现GG思密达...
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int x[],y[];
int main()
{
int n,a,b,sum=;
cin>>n>>a>>b;
if(a>b) swap(a,b);
for(int i=;i<=n;i++) cin>>x[i]>>y[i];
for(int i=;i<=n;i++)
for(int j=i+;j<=n;j++)
{
int sumx,sumy;
sumx=x[i]+x[j],sumy=max(y[i],y[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]); sumx=x[i]+y[j],sumy=max(y[i],x[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]); sumx=y[i]+x[j],sumy=max(x[i],y[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]); sumx=y[i]+y[j],sumy=max(x[i],x[j]);
if(sumx>sumy) swap(sumx,sumy);
if(sumx<=a&&sumy<=b) sum=max(sum,x[i]*y[i]+x[j]*y[j]);
}
cout<<sum<<endl;
return ;
}
Educational Codeforces Round 26 A B C题的更多相关文章
- Educational Codeforces Round 26
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...
- CodeForces 837F - Prefix Sums | Educational Codeforces Round 26
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...
- CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26
/* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...
- CodeForces 837D - Round Subset | Educational Codeforces Round 26
/* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...
- Educational Codeforces Round 26 [ D. Round Subset ] [ E. Vasya's Function ] [ F. Prefix Sums ]
PROBLEM D - Round Subset 题 OvO http://codeforces.com/contest/837/problem/D 837D 解 DP, dp[i][j]代表已经选择 ...
- Educational Codeforces Round 26 F. Prefix Sums 二分,组合数
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/72 ...
- Educational Codeforces Round 26 B,C
B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...
- Educational Codeforces Round 14 B. s-palindrome 水题
B. s-palindrome 题目连接: http://www.codeforces.com/contest/691/problem/B Description Let's call a strin ...
- Educational Codeforces Round 26 D dp
D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
随机推荐
- Codeforces 612B. Wet Shark and Bishops 模拟
B. Wet Shark and Bishops time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
- 一名优秀的UI设计师应该具备哪些条件?
想做好一个好的UI设计师除了应该具有一定的审美能力,还要了解整个产品的开发过程,因为目前国内的软件行业还不能对UI设计形成应有的重视度,所以对我们的要求就更高了,你要能作出夺人眼球的东西,还要站在用户 ...
- 连接redis
- socketpair初识
#include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/typ ...
- AJAX初尝试——ACM/ICPC类比赛气球管理系统
很早之前做过一个,白板没界面,20秒暴力刷新,数据库每个team一个n列的对应n个题目的标记项,只能对单个比赛暴力把全部user_id导入单独的气球表(也就是cid=1000用这个表的话,cid100 ...
- Linux IPC 之信号量
信号量(也叫信号灯)是一种用于提供不同进程间或一个给定进程的不同线程间同步手段的原语. 信号量是进程/线程同步的一种方式,有时候我们需要保护一段代码,使它每次只能被一个执行进程/线程运行,这种工作就需 ...
- json&pickle
用于序列化的两个模块 json,用于字符串 和 python数据类型间进行转换pickle,用于python特有的类型 和 python的数据类型间进行转换Json模块提供了四个功能:dumps.du ...
- HDU 1106 排序 (排序+处理字符串)
题意:略. 析:按照题目说的,把字符串分割,然后把字符串转成十进制,存起来,可以用数组,我用的向量, 排序一下就OK了.注意的是,要考虑多个5相邻的时候,刚开始没考虑WA了一次. 代码如下: #inc ...
- DataFrame按行读取:DataFrame之values
http://blog.csdn.net/u014607457/article/details/51290582 def fill_core(self): RatingTable=pd.read_cs ...
- DIV+CSS实战(三)
一.说明 在上篇博客<DIV+CSS实战(二)>中,实现了头部以及Tab标签卡,下面开始实现内容区域,要实现的效果如下: 二.内容最外层的设计(边框) 给最外层加边框,并且设置高度随着里面 ...