Educational Codeforces Round 26 B,C
B. Flag of Berland
链接:http://codeforces.com/contest/837/problem/B
思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出三个字母的边界,算下面积,是否和数量相同,不相同的话肯定不为条纹型,然后判断下他们宽和高的关系就行了
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
//void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=1;y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
//ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
//int gcd(int a,int b) { return (b>0)?gcd(b,a%b):a; }
//int lcm(int a, int b) { return a*b/gcd(a, b); } int main()
{
int n,m,en_rx=,be_rx=inf,en_ry=,be_ry=inf,en_gx=,en_gy=,en_bx=,en_by=,be_gx=inf,be_gy=inf,be_bx=inf,be_by=inf,r,g,b;
char mp[][];
sdd(n,m);
r=;g=;b=;
ff(i,,n){
ff(j,,m){
cin>>mp[i][j];
if(mp[i][j]=='R'){
r++; en_rx = max(i,en_rx);en_ry = max(j,en_ry);be_rx=min(i,be_rx);be_ry=min(j,be_ry);}
if(mp[i][j]=='G'){ g++; en_gx = max(i,en_gx);en_gy = max(j,en_gy);be_gx=min(i,be_gx);be_gy=min(j,be_gy);}
if(mp[i][j]=='B'){ b++; en_bx = max(i,en_bx);en_by = max(j,en_by);be_bx=min(i,be_bx);be_by=min(j,be_by);}
}
}
if(n*m<){
cout<<"NO"<<endl;return ;}
int num = (en_rx - be_rx+)*(en_ry - be_ry+);
//cout<<num<<endl;
//cout<<en_gx<<" "<<be_gx<<endl;
//cout<<en_ry<<" "<<be_ry<<endl;
if((en_rx - be_rx)==(en_gx - be_gx)&&(en_gx - be_gx)==(en_bx - be_bx)&&(en_ry - be_ry)==(en_gy - be_gy)&&(en_gy - be_gy)==(en_by - be_by)&&num==r)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}
C. Two Seals
题目链接:http://codeforces.com/contest/837/problem/C
思路:
给你几个方块,让你选两个方块放在a*b范围里,要求面积最大,方块可以转90度,直接暴力模拟就是了
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x[],y[];
int a,b;
ll max(ll x,ll y)
{
if(x>y) return x;
return y;
}
bool check(int i,int j){
ll a1=x[i]+x[j],b1=max(y[i],y[j]);
ll a2=y[i]+x[j],b2=max(x[i],y[j]);
ll a3=x[i]+y[j],b3=max(y[i],x[j]);
ll a4=y[i]+y[j],b4=max(x[i],x[j]);
if((a1<=a && b1<=b) || (a2<=a && b2<=b) || (a3<=a && b3<=b) || (a4<=a && b4<=b))
return true;
if((a1<=b && b1<=a) || (a2<=b && b2<=a) || (a3<=b && b3<=a) || (a4<=b && b4<=a))
return true;
return false;
}
int main()
{
int n,c=,y1,x1,i,j;
cin>>n>>a>>b;
for(i=;i<n;i++)
cin>>x[i]>>y[i];
ll ans = ,maxx = ;
for(i=;i<n-;i++){
for(j=i+;j<n;j++){
if(check(i,j)==){
ans = x[i]*y[i]+x[j]*y[j];
//cout<<i<<" "<<j<<" "<<ans<<endl;
maxx = max(maxx,ans);
}
}
}
cout<<maxx<<endl;
return ;
}
ps:好鸡儿菜啊,打了一年还是这么水。
Educational Codeforces Round 26 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 D dp
D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- 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 E - Vasya's Function
数论题还是好恶心啊. 题目大意:给你两个不超过1e12的数 x,y,定义一个f ( x, y ) 如果y==0 返回 0 否则返回1+ f ( x , y - gcd( x , y ) ); 思路:我 ...
- Educational Codeforces Round 26 A B C题
题目链接 A. Text Volume 题意:计算句子中,每个单词大写字母出现次数最多的那个的出现次数(混不混乱QAQ). 解题思路:注意getchar()就没啥了. #include<cstd ...
随机推荐
- 最近开始学习Cesium,学习学习。
最近开始学习Cesium,学习学习.
- Java 面试题 == 和 equals 的区别
int和Integer的区别 1.Integer是int的包装类,int则是java的一种基本数据类型 2.Integer变量必须实例化后才能使用,而int变量不需要 3.Integer实际是对象的引 ...
- vue 结合mint-ui Message box的使用方法
两种方式使用: 一.全局注册 1.在main.js中引入 //引入 import { MessageBox } from 'mint-ui'; //全局使用,挂载到原型上 Vue.prototyp ...
- Centos7 64位 -- glibc-2.29 编译升级方法(已成功)
某软件出现漏洞,需要升级解决(忘了哪个)结果提示glibc版本过低. 懵懂无知的我以为glibc想其他软件一样编译升级一下就好.. 结果? 重装系统! 说真的,如非必要(或学习),请勿升级 glibc ...
- C#大型电商项目优化(三)——扩展性与支付
上一篇文章引来不少非议,笔者并非对EF有看法,而是针对不同的业务场景和框架背景,挑选不同的方案.每个方案都有其优势劣势,挑选最快速,最简单的方案,是笔者的初衷. 看评论也是学习的过程,然而有些只做评价 ...
- Centos7下关于系统用户密码规则-运维笔记
针对Centos7下的系统用户的密码规则复杂度的设置,处于安全考虑,说明如下: 一.设置密码规则 1)密码长度.有效期 /etc/login.defs文件是当创建用户时的一些规划,比如创建用户时,是否 ...
- Centos6.8下编译安装LAMP的操作记录梳理
之前用的最多的web框架是LNMP,偶尔也会用到LAMP.接下来简单说下LAMP环境的部署记录,这里选择源码安装的方式: LAMP相关安装包下载地址:https://pan.baidu.com/s/1 ...
- Educational Codeforces Round 49 (Rated for Div. 2)A到C题
A题意 给你t表示有t组测试数据,每组数据给你一个含小写字母的字符串,每个字符必须变为它相邻的字符,问最后是否能变成回文串.a不能变成z,反过来也不行 分析 只需对对称位置判断差是否小于2且不等于1, ...
- CF1016 D. Vasya And The Matrix
传送门 [http://codeforces.com/group/1EzrFFyOc0/contest/1016/problem/D] 题意 已知矩阵n行m列,以及每一行,每一列所有元素的异或,用 a ...
- SCRUM 12.21
从爬虫遇到的问题中我们学会了: 1.有的网站是有反爬虫机制的,外卖网站(我们猜测基本所有盈利性质的网站可能都是)全部都有. 2.我们对于反爬虫机制有了一定的了解. 本次爬虫测试中,我们最后连美团网 ...