暴力/思维 HDOJ 5386 Cover
/*
题意:给出刷墙的所有的方法,求一种顺序,使得原矩阵刷成目标矩阵
暴力:(题解)我们只要每次找一行或一列颜色除了0都相同的,然后如果有对应的操作,就把这行这列都赋值成0即可
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-13 21:25:07
* File Name :G.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e2 + ;
const int MAXM = 5e2 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
int a[MAXN][MAXN];
int b[MAXM], c[MAXM];
char op[MAXM];
int ans[MAXM]; int main(void) { //HDOJ 5386 Cover
int T; scanf ("%d", &T);
while (T--) {
int n, m; scanf ("%d%d", &n, &m);
for (int i=; i<=n; ++i) {
for (int j=; j<=n; ++j) {
scanf ("%d", &a[i][j]);
}
}
for (int i=; i<=n; ++i) {
for (int j=; j<=n; ++j) {
scanf ("%d", &a[i][j]);
}
}
for (int i=; i<=m; ++i) {
char ch;
for (ch=getchar (); ch!='H'&&ch!='L'; ch=getchar ()) ;
op[i] = ch; scanf ("%d%d", &b[i], &c[i]);
} int t = ;
while (t < m) {
for (int i=; i<=m; ++i) {
if (!b[i]) continue;
if (op[i] == 'H') {
int x = b[i]; bool flag = true;
for (int j=; j<=n; ++j) {
if (a[x][j] && a[x][j] != c[i]) {
flag = false; break;
}
}
if (flag) {
ans[++t] = i; b[i] = ;
for (int j=; j<=n; ++j) a[x][j] = ;
}
}
else {
int y = b[i]; bool flag = true;
for (int j=; j<=n; ++j) {
if (a[j][y] && a[j][y] != c[i]) {
flag = false; break;
}
}
if (flag) {
ans[++t] = i; b[i] = ;
for (int j=; j<=n; ++j) a[j][y] = ;
}
}
}
} for (int i=m; i>=; --i) printf ("%d%c", ans[i], (i == ) ? '\n' : ' ');
} return ;
}
暴力/思维 HDOJ 5386 Cover的更多相关文章
- hdoj 5386 Cover
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5386 倒着推的一个挺暴力的题,看着和数学有关系,然而并没有, 不要一看到含有数学元素就考虑这是一个数学 ...
- hdu 5386 Cover (暴力)
hdu 5386 Cover Description You have an matrix.Every grid has a color.Now there are two types of oper ...
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...
- DFS/BFS+思维 HDOJ 5325 Crazy Bobo
题目传送门 /* 题意:给一个树,节点上有权值,问最多能找出多少个点满足在树上是连通的并且按照权值排序后相邻的点 在树上的路径权值都小于这两个点 DFS/BFS+思维:按照权值的大小,从小的到大的连有 ...
- 模拟+思维 HDOJ 5319 Painter
题目传送门 /* 题意:刷墙,斜45度刷红色或蓝色,相交的成绿色,每次刷的是连续的一段,知道最终结果,问最少刷几次 模拟+思维:模拟能做,网上有更巧妙地做法,只要前一个不是一样的必然要刷一次,保证是最 ...
- HDU 5386 Cover(模拟)
Cover Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Subm ...
- 【洛谷】P1275 魔板(暴力&思维)
题目描述 有这样一种魔板:它是一个长方形的面板,被划分成n行m列的n*m个方格.每个方格内有一个小灯泡,灯泡的状态有两种(亮或暗).我们可以通过若干操作使魔板从一个状态改变为另一个状态.操作的方式有两 ...
- HDU 5386 Cover
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5386 题目大意:给一个初始矩阵(n×n).一个目标矩阵(n×n)和m个操作,要求找到一种操作顺序,使初 ...
- codeforce 985B Switches and Lamps(暴力+思维)
Switches and Lamps time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- [K/3Cloud] 如何设置设置单据分录中的整列的精度
有时,你可能想设置整列的精度,可以在插件中完成. 设置方法如下 : this.View.GetFieldEditor<DecimalFieldEditor>("FAmount&q ...
- windows开启远程
windows开启远程桌面超级简单,跟linux相比太简单了. 补充:有瑕疵,应该是远程中的远程桌面属性打钩,但是W8.1没有这个选项,W7可以,其次创建一个管理员账户,身份是管理员,不是标准用户,要 ...
- ubuntu14.04 配置网络
ubuntu14.04 配置网络的练习 本文参考的资料: https://blog.csdn.net/liu782726344/article/details/52912797. 感谢作者的分享! 打 ...
- [bzoj1934/2768][Shoi2007]Vote 善意的投票_最小割
Vote 善意的投票 bzoj-1934 Shoi-2007 题目大意:题目链接. 注释:略. 想法: 这是最小割的一个比较基本的模型. 我们将所有当前同意的小朋友连向源点,边权为1.不容易的连向汇点 ...
- Servlet的客户端请求
以下内容引用自http://wiki.jikexueyuan.com/project/servlet/client-request.html: 当浏览器请求网页时,它会向Web服务器发送大量信息,这些 ...
- 我的arcgis培训照片5
来自:http://www.cioiot.com/successview-528-1.html
- 使用adb在电脑和手机间传文件
首先须要root手机. 然后,"Win + R",打开cmd窗体.以下以copy d:\1.txt到/system/文件夹为例说明. adb push source(localpa ...
- Unity 5.x 导入教学Demo
前言 小巫也来玩Unity3D了.以后会把学习的一些过程博客记录下来,方大家也方便自己学习和查看.本篇博客介绍怎样在Unityclient中导入Assert Store中下载的项目资源,方便我们进一步 ...
- Android学习笔记-listview实现方式之BaseAdapter
listview是Android开发中最为常用的组件,这里我们就学习一下用BaseAdapter的方式实现listview, 主布局activity_main.xml是这样的: <LinearL ...
- java web中的session属性范围和request属性范围
首先必需要了解client跳转和server端跳转的差别: client跳转: response.sendRedict(String path).地址栏发生改变. 不能传递request属性. ser ...