ZOJ - 3954 Seven-Segment Display 相对位置-模拟

题意:

改变列的相对位置,看看新的行列式是否合法


思路:

只要如果合法的话,每一列的中各行的相对位置的数对应都是不变的,,也就是我们只需要看改变前后时候存在相同的序列就是了


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define kuaidian ios::sync_with_stdio(0);

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 5e4, maxd = 1e8;
const ll mod = 1e9 + 7;
const ll INF = 0x7f7f7f7f;

int n, a[10];
char s[10][10];
map<string, int> mp;

char ss[10][10] = {
    "0000000",
    "1001111",
    "0010010",
    "0000110",
    "1001100",
    "0100100",
    "0100000",
    "0001111",
    "0000000",
    "0000100"
};

void init() {

}

int main() {
    init();

    int T;
    scanf("%d", &T);
    while(T--) {
            mp.clear();
        int n;
        scanf("%d", &n);
        for(int i = 0; i < n; ++i) {
            scanf("%d%s", &a[i], s[i]);
        }
        string s1, s2, s3, s4, s5, s6, s7;
        for(int i = 0; i < n; ++i) {
            s1.push_back(ss[a[i]][0]);
            s2.push_back(ss[a[i]][1]);
            s3.push_back(ss[a[i]][2]);
            s4.push_back(ss[a[i]][3]);
            s5.push_back(ss[a[i]][4]);
            s6.push_back(ss[a[i]][5]);
            s7.push_back(ss[a[i]][6]);
        }
//        cout << s1 << endl;
//        cout << s2 << endl;
//        cout << s3 << endl;
//        cout << s4 << endl;
//        cout << s5 << endl;
//        cout << s6 << endl;
//        cout << s7 << endl;

        mp[s1]++;
        mp[s2]++;
        mp[s3]++;
        mp[s4]++;
        mp[s5]++;
        mp[s6]++;
        mp[s7]++;

        s1.clear();
        s2.clear();
        s3.clear();
        s4.clear();
        s5.clear();
        s6.clear();
        s7.clear();

        for(int i = 0; i < n; ++i) {
            s1.push_back(s[i][0]);
            s2.push_back(s[i][1]);
            s3.push_back(s[i][2]);
            s4.push_back(s[i][3]);
            s5.push_back(s[i][4]);
            s6.push_back(s[i][5]);
            s7.push_back(s[i][6]);
        }

//        cout << s1 << endl;
//        cout << s2 << endl;
//        cout << s3 << endl;
//        cout << s4 << endl;
//        cout << s5 << endl;
//        cout << s6 << endl;
//        cout << s7 << endl;

        int f = 0;
        if(mp[s1] == 0) f = 1;
        else mp[s1]--;

        if(mp[s2] == 0) f = 1;
        else mp[s2]--;

        if(mp[s3] == 0) f = 1;
        else mp[s3]--;

        if(mp[s4] == 0) f = 1;
        else mp[s4]--;

        if(mp[s5] == 0) f = 1;
        else mp[s5]--;

        if(mp[s6] == 0) f = 1;
        else mp[s6]--;

        if(mp[s7] == 0) f = 1;
        else mp[s7]--;

        if(!f) puts("YES");
        else puts("NO");
    }

    return 0;
}















  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值