Madoka and Childish Pranks(贪心)
Madoka and Childish Pranks
题意 :
这题的意思有点难懂,大概题意是,原本有n ∗ m 的网格,然后每次操作只能按棋盘图案操作,就是只能画一个类似棋盘的图案,比如样例1,第一步,画了一个3 ∗ 3 的正方形,按照棋盘的规则(黑白相间,第一个为白),第二步也是画了个棋盘不过是2*2的。最后她给出画的样子,要你用这个方法画出来。
显然第三种不能画,第一种可以画,第二种不用动。所以我们看到第一行第一个为黑就可以NO了。而且,很关键的是,他不需要你求最小步数,只要画出来就成功。所以我们试着每次只涂两个,从后面涂到前面,其实发现,只要第一个不是黑色,全部都能涂,只不过是用最多次数来涂,遍历所需数组,遇到1就涂(前一格和这一格(两格)),如果在第一列,就涂这一格和上面一格(第一行第一列除外)。
AC代码 :
#include <iostream>
#include <algorithm>
#include <cstring>using namespace std;
const int N = 110;
char a[N][N];struct node {int x1, y1, x2, y2;
}cnt[N*N];void solve() {int n, m;cin >> n >> m;for(int i = 1; i <= n; i++)for(int j = 1; j <= m; j++)cin >> a[i][j];if(a[1][1] == '1') {cout << -1 << endl;return;}int k = 0;for(int i = n; i; i--)for(int j = m; j; j--) {if(a[i][j] == '0') continue;if(j != 1) {cnt[k].x1 = i, cnt[k].y1 = j - 1, cnt[k].x2 = i, cnt[k].y2 = j;k++;}else {cnt[k].x1 = i - 1, cnt[k].y1 = j, cnt[k].x2 = i, cnt[k].y2 = j; k++;}}cout << k << endl;for(int i = 0; i < k; i++) cout << cnt[i].x1 << ' ' << cnt[i].y1 << ' ' << cnt[i].x2 << ' ' << cnt[i].y2 << endl;
}
int main() {int t;cin >> t;while(t--) {solve();}return 0;
}
Madoka and Childish Pranks(贪心)相关推荐
- C. Madoka and Childish Pranks #777 div2
Problem - C - Codeforces 题意是给你一个01矩阵,按照画象棋的模式能不能把一个全部是0的矩阵变成给的矩阵 这题想的复杂了一点点,其实还好 这题明白了之后发现构造题的漂亮了 首先 ...
- Codeforces Round #777 (Div. 2)
7月19日 A Madoka and Math Dad B Madoka and the Elegant Gift C Madoka and Childish Pranks A Madoka and ...
- Codeforces Round #777 (Div. 2) 简训
Codeforces Round #777 (Div. 2) 简训 导语 涉及的知识点 题目 A Madoka and Math Dad B Madoka and the Elegant Gift C ...
- Codeforces Round #777 (Div. 2)【未完结】
老年选手,做个签到就溜了. 现在才开始补题,cf分一直上不去. 目录 A. Madoka and Math Dad[构造] B. Madoka and the Elegant Gift[连通块] C. ...
- 【CF #777 div2】A-C
A. Madoka and Math Dad 题目 分析 给一个n,构造一个数字,使这个数字每位和为n且这个数字相邻各位不能相等,且这个数是所有数中最大的. 要使数字最大,肯定要使位数尽可能的多,而且 ...
- Codeforces Round #777 (Div. 2)(A~C)
原题链接: A. Madoka and Math Dad B. Madoka and the Elegant Gift C. Madoka and Childish Pranks A. Madoka ...
- 【记录CF】Codeforces Round #777 (Div. 2) A~C 题解
目录 杂谈 A. Madoka and Math Dad B. Madoka and the Elegant Gift C. Madoka and Childish Pranks 杂谈 又是一场离谱掉 ...
- Codeforces Round #777 (Div. 2) (A-D题解)
源代码:ACM/OpenjudgeNow/Codeforces at master · abmcar/ACM (github.com) 更好的阅读体验: 折跃坐标 碎碎念:不亏是俄罗斯场+二次元出题人 ...
- Codeforces Round #777 (Div. 2) 题解
Codeforces #777 题解 这次带上了大佬前来验题xs 公开大佬珍贵的代码资源供参考 TOC A.Madoka and Math Dad B.Madoka and the Elegant G ...
最新文章
- Linux IO多路复用之epoll网络编程(含源码)
- C# 错误!!容量超出了最大容量。参数名: capacity 这个是什么问题呢?
- 084_html5WebWorkers
- Hbase(1)——基础语句(1)
- aix oracle 内存限制,请教 AIX 与 Linux 中,怎样分析Oracle的内存占用?
- 如何为我们的应用程序提供一个更小、更快的视频通话库
- 【图论】(二分图)J. Burnished Security Updates - CodeForces
- 电脑黑屏故障的解决方案
- 移植marvell poncat3 demo板的总结
- visio 2010 激活方法
- 小米笔记本pro频繁蓝屏故障解决
- oracle删临时表,ORACLE中创建和删除临时表
- Eclipse下载、安装、配置教程
- Cousera吴恩达机器学习week7笔记
- Android网络收音机项目
- 神奇的二进制转换和运算
- mac os php Phalcon拓展
- 『 论文阅读』LightGBM原理-LightGBM: A Highly Efficient Gradient Boosting Decision Tree
- 数字化助力社区抗疫———物资管理系统
- [Python]tabulate可如此优雅地创建表格