ZOJ3954 Seven-Segment Display

题意:

  emmmm见原题吧

分析:

  这也是当时省赛选拔的题,场上以为是大模拟,然后没敢写。。。补题发现是道水题···

  因为每一列的顺序不一定,但是行是一定的。所以只要把每一列组成一个数字,然后弄两个集合,然后比一下是否相同就可以了

 code

 

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #include <iostream>
 5 
 6 using namespace std;
 7 const int maxn=100;
 8 char *G[maxn];
 9 
10 int T,n;
11 
12 struct Node{
13     int num;
14     char g[maxn];
15     bool operator <(const Node &rhs)const{
16         return num<rhs.num;
17     }
18 }node[maxn];
19 int a[maxn],b[maxn];
20 bool judge(int len){
21     sort(a+1,a+1+len);
22     sort(b+1,b+1+len);
23     for(int i=1;i<=len;i++){
24         if(a[i]!=b[i]){
25             return false;
26         }
27     }
28     return true;
29 }
30 int main(){
31     G[0]={"1011011"};
32     G[1]={"0000110"};
33     G[2]={"0010010"};
34     G[3]={"0011001"};
35     G[4]={"0110000"};
36     G[5]={"0100000"};
37     G[6]={"1011010"};
38     G[7]={"0000000"};
39     G[8]={"0010000"};
40     scanf("%d",&T);
41     for(int t=1;t<=T;t++){
42         scanf("%d",&n);
43         for(int i=1;i<=n;i++){
44             scanf("%d",&node[i].num);
45             for(int j=0;j<7;j++){
46                 scanf(" %c",&node[i].g[j]);
47             }
48         }
49         sort(node+1,node+1+n);
50         long long num=0;
51         for(int i=0;i<7;i++){
52                 long long res=0;
53             for(int j=1;j<=n;j++){
54                 res=res*10+(node[j].g[i]-'0');
55             }
56             num++;
57             a[num]=res;
58         }
59 
60         long long num1=0;
61         for(int i=0;i<7;i++){
62             long long res=0;
63             for(int j=1;j<=n;j++){
64                 res=res*10+(G[node[j].num-1][i]-'0');
65             }
66             num1++;
67             b[num1]=res;
68         }
69         if(judge(num1)){
70             printf("YES\n");
71         }else{
72             printf("NO\n");
73         }
74     }
75     return 0;
76 }
View Code

猜你喜欢

转载自www.cnblogs.com/LQLlulu/p/8932186.html