码迷,mamicode.com
首页 > 其他好文 > 详细

hdoj 5386 Cover

时间:2015-08-16 13:45:47      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5386

倒着推的一个挺暴力的题,看着和数学有关系,然而并没有,

不要一看到含有数学元素就考虑这是一个数学题,很有可能用编程思想去推导。

这道题就是倒着暴力去做就行,暴力类的题不容易debug,

注意输入输出一定不要出问题。

 1 #include<stdio.h>
 2 const int MAXN1 = 105;
 3 const int MAXN2 = 505;
 4 int T;
 5 int m, n;
 6 int a[MAXN1][MAXN1];
 7 char op[MAXN2];
 8 int ope[MAXN2][2];
 9 int mop[MAXN2];
10 int t;
11 bool flag;
12 char ch;
13 void Read(){
14     scanf("%d%d",&n,&m);
15     for(int i = 0; i < n; ++i)
16         for(int j = 0; j < n; ++j)
17             scanf("%d",&a[i][j]);
18     for(int i = 0; i < n; ++i)
19         for(int j = 0; j < n; ++j)
20             scanf("%d",&a[i][j]);
21     for(int i = 0; i < m; ++i){
22         ch = getchar();
23         while( ch != H && ch != L)
24             ch = getchar();
25         op[i] = ch;
26         scanf("%d %d",&ope[i][0],&ope[i][1]);
27     }
28 }
29 int main(){
30 //    freopen("a.txt","r",stdin);
31     scanf("%d",&T);
32     while(T--){
33         t = 0;
34         Read();
35         while(t<m){
36             for(int k = 0; k < m; ++k){
37                 if(ope[k][0]){
38                     if(op[k] == H){
39                         flag = 1;
40                         for( int i = 0; i < n; ++i){
41                             if(a[ope[k][0]-1][i] != ope[k][1] && a[ope[k][0]-1][i]){
42                                 flag = 0;
43                                 break;
44                             }
45                         }
46                         if(flag){
47                             for(int i = 0; i < n; ++i)
48                                 a[ope[k][0]-1][i] = 0;
49                             ope[k][0] = 0;
50                             mop[t++] = k;
51                         }
52                     }
53                     if(op[k] == L){
54                         flag = 1;
55                         for( int i = 0; i < n; ++i){
56                             if(a[i][ope[k][0]-1] != ope[k][1] && a[i][ope[k][0]-1]){
57                                 flag = 0;
58                                 break;
59                             }
60                         }
61                         if(flag){
62                             for(int i = 0; i < n; ++i){
63                                 a[i][ope[k][0]-1] = 0;
64                             }
65                             mop[t++] = k;
66                             ope[k][0] = 0;
67                         }
68                     }
69                 }
70             }
71         }
72         for(int i = m-1; i >= 0; --i){
73             printf("%d",mop[i]+1);
74             if( i != 0 )
75                 printf(" ");
76         }
77         printf("\n");
78     }
79 }

 

hdoj 5386 Cover

标签:

原文地址:http://www.cnblogs.com/blueprintf/p/4734073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!