Educational Codeforces Round 26 - A, B, C 思维
比赛链接: http://codeforces.com/contest/837
A: Text Volume 水
B: Flag of Berland
题目描述: 给你一个字符矩阵, 问能不能形成三条条纹
解题思路: 纯细节题, 中间因为马虎WA了几次
代码:
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <cstring> #include <iterator> #include <cmath> #include <algorithm> #include <stack> #include <deque> #include <map> #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 #define mem0(a) memset(a,0,sizeof(a)) #define meminf(a) memset(a,0x3f,sizeof(a)) using namespace std;int cnt[9]; char g[110][110];int main() {mem0(cnt);mem0(cnt);int n, m;cin >> n >> m;for( int i = 1; i <= n; i++ ) {for( int j = 1; j <= m; j++ ) {cin >> g[i][j];if(g[i][j] == 'R') cnt[0]++;else if(g[i][j] == 'G') cnt[1]++;else cnt[2]++;}}if( (n%3!=0) && (m%3!=0) ) {cout<< "NO" << endl;return 0;}int flag1 = 1;int flag2 = 1;if( cnt[0] == cnt[1] && cnt[1] == cnt[2] ) {if( n % 3 == 0 ) {char temp0 = g[1][1];for( int i = 1; i <= n / 3; i++ ) {for( int j = 1; j <= m; j++ ) {if( g[i][j] != temp0 ) {flag1 = 0;}}}char temp1 = g[n/3+1][1];for( int i = n/3+1; i <= 2*n/3; i++ ) {for( int j = 1; j <= m; j++ ) {if(g[i][j] != temp1) {flag1 = 0;}}}}else flag1 =0;if( m % 3 == 0 ) { // cout << "=" << endl;char temp0 = g[1][1];for( int i = 1; i <= n; i++ ) {for( int j = 1; j <= m/3; j++ ) {if(g[i][j] != temp0) {flag2 = 0;}}}char temp1 = g[1][m/3+1];for( int i = 1; i <= n; i++ ) {for( int j = m/3+1; j <= 2*m/3; j++ ) {if(g[i][j] != temp1) {flag2 = 0;}}}}else flag2 = 0;if(flag1 + flag2 > 0) { // cout << flag1 << " " << flag2 << endl;cout << "YES" << endl;return 0;}else {cout << "NO" << endl;return 0;}}else {cout << "NO" << endl;}return 0; }
B
思考: 自己还是不够细心, 这题本来是不应该WA的
C: Two seals
题目描述: 在一块长为a * b的矩形中放置两个矩形, 所选的矩形从输入的N个矩形中选, 要求必须放两个而且不能重叠, 不能超边界
解题思路: 这题我傻逼了.....暴力就行, 开一个2 * n的数组,将旋转后的矩形也放进去, 这样可以方便一点, 然后判断两个矩形能不能放在一起, (a-y[i], b) 或者 (a, b-x[i]) 在这两个任意一个区间就可以, 一步步更新最大值即可
代码:
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <cstring> #include <iterator> #include <cmath> #include <algorithm> #include <stack> #include <deque> #include <map> #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 #define mem0(a) memset(a,0,sizeof(a)) #define meminf(a) memset(a,0x3f,sizeof(a)) using namespace std;int dp[220][220][4]; int x[220]; int y[220];int main() {int n;int a, b;cin >> n >> a >> b;for( int i = 1; i <= 2*n; i+=2 ) {cin >> x[i] >> y[i];x[i+1] = y[i], y[i+1] = x[i];}int ans = 0;for( int i = 1; i <= 2*n; i++ ) {for( int j = 1; j <= 2*n; j++ ) {if( i != j && !((i&1)&&j==i+1) && !(!(i&1)&&j==i-1) ) {int temp1 = a-y[i];int temp2 = b-x[i];if( x[j] <= temp1 && y[j] <= b && temp2 >= 0 ) {ans = max( ans, x[i]*y[i]+x[j]*y[j] );}if( x[j] <= a && y[j] <= temp2 && temp1 >= 0 ) {ans = max( ans, x[i]*y[i]+x[j]*y[j] );}}}}cout << ans << endl;return 0; }
C
思考: 一开始傻逼了......去向用DP做, 状态转移方程半天没有想出来, 原因就是DP的时候如果是当前是第j个, 就必须知道上一个是放了一个还是没放, 很复杂, 再说n这么小不暴力傻逼啊
比赛总结: 只做出了A, B , C 剩下的也是可以补的题, 今天要补补了........
转载于:https://www.cnblogs.com/FriskyPuppy/p/7358681.html
Educational Codeforces Round 26 - A, B, C 思维相关推荐
- Educational Codeforces Round 98 -B - Toy Blocks (思维)
题目链接 题目大意: n个盒子,每个盒子里有a[i]个球, 对于任意一个盒子,可以把其中的球随意分配到其他(n-1)个盒子当中,使得n-1个盒子中的球数目相等,求 向n个盒子中最少添加多少个球才能实现 ...
- Educational Codeforces Round 73 (Rated for Div. 2) E. Game With String 思维博弈 好题(2500)
传送门 文章目录 题意: 思路: 题意: 思路: 我们将每一段...拿出来看成若干段,将其分成以下四种情况: (1)len<b(1)len<b(1)len<b (2)b≤len< ...
- Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest 思维 + 差分
传送门 文章目录 题意: 思路: 题意: 给你三个长度分别为k1,k2,k3k1,k2,k3k1,k2,k3的数组a,b,ca,b,ca,b,c,其中k1+k2+k3=nk1+k2+k3=nk1+k2 ...
- Educational Codeforces Round 84 (Rated for Div. 2) D. Infinite Path 构建环 + 思维
传送门 文章目录 题意: 思路: 题意: 懒得写了,直接贴图了. 思路: 遇事不决画成图,考虑将iii向p[i]p[i]p[i]连一个边,可以发现每个点入度为111,出度为111,所以画出来是若干个环 ...
- Educational Codeforces Round 86 (Rated for Div. 2) Apr/26/2020 22:35UTC+8
Educational Codeforces Round 86 Rated for Div. 2 A. Road To Zero B. Binary Period(找最小周期) C. Yet Anot ...
- Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)
Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...
- Educational Codeforces Round 111 (Rated for Div. 2) E. Stringforces 二分 + 状压dp
传送门 文章目录 题意: 思路: 题意: 给你一个串,只包含前kkk个字母和???,定义fif_ifi表示第iii个字母在串中出现的最长连续长度,你现在需要将???替换为前kkk个字母,使得mini ...
- Educational Codeforces Round 111 (Rated for Div. 2)
Educational Codeforces Round 111 (Rated for Div. 2) 题号 题目 知识点 A Find The Array B Maximum Cost Deleti ...
- Educational Codeforces Round 107 (Rated for Div. 2)
Educational Codeforces Round 107 (Rated for Div. 2) 题号 题目 知识点 A Review Site 签到 B GCD Length 思维+构造 C ...
- Educational Codeforces Round 103 (Rated for Div. 2)A~E解题报告
Educational Codeforces Round 103 (Rated for Div. 2) A. K-divisible Sum 原题信息 解题思路 AC代码 #include <b ...
最新文章
- 浏览器URL地址里一堆%或者6E616D6531之类的是啥?编码
- spring定时任务重复执行2次问题的解决
- 【数据结构-树】1.树与森林(树的遍历、树的存储方法、并查集的实现)
- [前端技术]如何加深对JavaScipt中的Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解...
- mysql 处理文本数据_MySQL ------ 数据处理函数(文本、日期、数值)(十)
- JVM监控工具介绍jstack, jconsole, jinfo, jmap, jdb, jsta (Linux 如何查看进程的各线程的CPU占用 )
- Android子线程更新UI的方法总结
- 【图像处理】——图像内插法
- 动态箭头gif图标_别以为只有专业人士才能做出酷炫的#动态跑分图#
- Netty 源码深度解析(九) - 编码
- Objective-C 相关Category
- 为什么float只有四个字节,存储范围却大于有八个字节的long类型?
- 基于Astar算法实现飞行轨迹的三维规划附Matlab代码
- postman接口测试工具的使用攻略
- Mipmap与纹理过滤
- 旅游攻略app开发定制
- Unity 引擎报错集锦
- 钉钉、微信抢占移动OA入口,其他OA厂商何去何从?
- 毕马威加入“华尔街区块链联盟”
- ArcGisPro脚本工具【8】——用地图斑导出用地用海汇总表
热门文章
- Python数据结构,线性结构:栈、队列、双端队列、列表
- 白鹭发布html5,白鹭Egret Engine 1.5发布 HTML5性能大幅提升
- python把float可以转变成int_在Python中将float转换为整数的最安全方法?
- DFS应用(拓扑排序和强连通分支)
- python中去除列表重复元素的方法汇总
- 操作系统课设 Nachos 实验一:Nachos 系统的安装与调试
- win10同时安装jdk8和jdk11带来的小坑
- androidid什么时候会变_高瓷绿松石是什么意思?为何绿松石的瓷度要比颜色重要?...
- javascript 数组所有方法
- macbook 安装任意来源