hdu5386 棋盘涂色模拟

http://acm.hdu.edu.cn/showproblem.php?pid=5386

Problem Description
You have an  nn matrix.Every grid has a color.Now there are two types of operating:
L x y: for(int i=1;i<=n;i++)color[i][x]=y;
H x y:for(int i=1;i<=n;i++)color[x][i]=y;
Now give you the initial matrix and the goal matrix.There are  m operatings.Put in order to arrange operatings,so that the initial matrix will be the goal matrix after doing these operatings

It's guaranteed that there exists solution.
 

Input
There are multiple test cases,first line has an integer  T
For each case:
First line has two integer  n, m
Then  n lines,every line has  n integers,describe the initial matrix
Then  n lines,every line has  n integers,describe the goal matrix
Then  m lines,every line describe an operating

1color[i][j]n
T=5
1n100
1m500
 

Output
For each case,print a line include  m integers.The i-th integer x show that the rank of x-th operating is  i
 

Sample Input
 
   
1 3 5 2 2 1 2 3 3 2 1 3 3 3 3 3 3 3 3 3 3 H 2 3 L 2 2 H 3 3 H 1 3 L 2 3
 

Sample Output
 
   
5 2 4 3 1

/** 
hdu5386  模拟 
题目大意:给一个棋盘涂色,每次操作给棋盘的某一列或一行涂上一种颜色,给定初始棋盘状态和最终棋盘状态,和一系列操作,请给这些序列排一个顺序 
解题思路:初始棋盘其实并没有什么用,我们从最终棋盘入手,每次找到一行或一列颜色全部一样的,如给定操作中有给这一行的如此操作,那么给此操作入队, 
          依次下去得到一个顺序,输出即可            
*/  
#include 
#include 
#include 
#include 
#include 
using namespace std;
const int maxn=105;
int a[maxn][maxn],n,m,x,y;
int judge[maxn*5],flag[maxn*5],num[maxn*5];
vector >x_vec[105],y_vec[105];
char s[10];
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d",&n,&m);
        int x;
        for(int i=0; i


你可能感兴趣的:(暴力和枚举)