题目传送门

 /*
题意:给出刷墙的所有的方法,求一种顺序,使得原矩阵刷成目标矩阵
暴力:(题解)我们只要每次找一行或一列颜色除了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的更多相关文章

  1. hdoj 5386 Cover

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5386 倒着推的一个挺暴力的题,看着和数学有关系,然而并没有, 不要一看到含有数学元素就考虑这是一个数学 ...

  2. hdu 5386 Cover (暴力)

    hdu 5386 Cover Description You have an matrix.Every grid has a color.Now there are two types of oper ...

  3. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

  4. DFS/BFS+思维 HDOJ 5325 Crazy Bobo

    题目传送门 /* 题意:给一个树,节点上有权值,问最多能找出多少个点满足在树上是连通的并且按照权值排序后相邻的点 在树上的路径权值都小于这两个点 DFS/BFS+思维:按照权值的大小,从小的到大的连有 ...

  5. 模拟+思维 HDOJ 5319 Painter

    题目传送门 /* 题意:刷墙,斜45度刷红色或蓝色,相交的成绿色,每次刷的是连续的一段,知道最终结果,问最少刷几次 模拟+思维:模拟能做,网上有更巧妙地做法,只要前一个不是一样的必然要刷一次,保证是最 ...

  6. HDU 5386 Cover(模拟)

    Cover Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Subm ...

  7. 【洛谷】P1275 魔板(暴力&思维)

    题目描述 有这样一种魔板:它是一个长方形的面板,被划分成n行m列的n*m个方格.每个方格内有一个小灯泡,灯泡的状态有两种(亮或暗).我们可以通过若干操作使魔板从一个状态改变为另一个状态.操作的方式有两 ...

  8. HDU 5386 Cover

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5386 题目大意:给一个初始矩阵(n×n).一个目标矩阵(n×n)和m个操作,要求找到一种操作顺序,使初 ...

  9. codeforce 985B Switches and Lamps(暴力+思维)

    Switches and Lamps time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. zoj4710暴力

    #include<stdio.h> #include<string.h> #define N 110 int map[N][N]; int main() { int n,m,k ...

  2. [JLOI2008]提示问题

    题目描述 最近在JLOI网上的一个流行游戏中,选手要回答很难的问题.假如在规定时间内不能回答,系统将给出1个提示,之后再依次给出第2,3个提示.出现在答案中的是字母和下列字符: '.',',',':' ...

  3. poj_2506_Tiling_201407211555

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7509   Accepted: 3672 Descriptio ...

  4. Bad Hair Day-POJ3250(简单的入栈出栈)

    Description Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow ...

  5. P1547 Out of Hay 洛谷

    https://www.luogu.org/problem/show?pid=1547 题目背景 奶牛爱干草 题目描述 Bessie 计划调查N (2 <= N <= 2,000)个农场的 ...

  6. 激活IDEA 2019.1

    First step: 先下载jar包JetbrainsCrack.jar,把它放到你认为合适的文件夹内, 我放在了安装目录C:\Program Files\JetBrains\IntelliJ ID ...

  7. springboot整合mybatis连接mysql数据库出现SQLException异常

    在springboot整合mybatis连接数据库的时候,项目中遇到一个SQLException,我检查了properties配置文件,看数据源有没有配错,检查有没有打错字,在数据库中把sql语句查询 ...

  8. Linux下tomcat的catalina.out屏蔽

    修改catalina.sh ,找到下面的位置: if [ -z "$CATALINA_OUT" ] ; then#CATALINA_OUT="$CATALINA_BASE ...

  9. MongoDB小结11 - update【save】

    save是一个shell函数,调用它,可以在文档不存在时插入,存在时更新,它只有一个参数:文档.如果文档有 _id 这个 键,那么save会调用upsert,否则会调用insert,非常方便.

  10. 013 IPv6

    Router>en Router#config t Enter configuration commands, one per line.  End with CNTL/Z. Router(co ...