题目链接

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3954

题意

有一块 LED 灯

然后上面有七块灯管

在显示不同数字的时候 由灯管的开关组合 来表现一个数字

给出一个标准表

然后 输入 一个表

求这个表 的 列 是可以交换的

然后 判断能否有一种经过若干次交换后的情况

这个表能够跟 标准表 相同

如果能 就输出 YES

不能 就输出 NO

思路

我们可以用MAP 存下 标准表的列 和 输入的表 的列

然后判断一下 两个MAP 是否完全相同

然后 输入的时候 要用 scanf 用 int 保存 不然会 超时

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> #define CLR(a) memset(a, 0, sizeof(a))
#define pb push_back using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, string> pss; const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-30; const int INF = 0x3f3f3f3f;
const int maxn = 1e4 + 5;
const int MOD = 1e9 + 7; int G[10][10];
int v[10][10]; struct Node
{
int n;
int v[10];
}q[10]; bool comp(Node x, Node y)
{
return x.n < y.n;
} void init()
{
CLR(G);
G[1][1] = G[1][4] = G[1][5] = G[1][6] = G[1][7] = 1;
G[2][3] = G[2][6] = 1;
G[3][5] = G[3][6] = 1;
G[4][1] = G[4][4] = G[4][5] = 1;
G[5][2] = G[5][5] = 1;
G[6][2] = 1;
G[7][4] = G[7][5] = G[7][6] = G[7][7] = 1;
G[9][5] = 1;
} int main()
{
init();
int t;
scanf("%d", &t);
while (t--)
{
CLR(v);
int n;
int arr[9];
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d", &q[i].n);
for (int j = 0; j < 7; j++)
scanf("%1d", &q[i].v[j]);
}
sort(q, q + n, comp);
map <int, int> vis[2];
int num = 0;
for (int i = 0; i < 7; i++)
{
num = 0;
for (int j = 0; j < n; j++)
{
num = num * 2 + q[j].v[i];
}
vis[0][num]++;
}
for (int i = 1; i <= 7; i++)
{
num = 0;
for (int j = 0; j < n; j++)
{
num = num * 2 + G[q[j].n][i];
}
vis[1][num]++;
}
map <int, int>::iterator it;
int flag = 1;
for (it = vis[0].begin(); it != vis[0].end(); it++)
{
if (vis[1][it->first] != it->second)
{
flag = 0;
break;
}
}
if (flag)
printf("YES\n");
else
printf("NO\n");
}
}

ZOJ - 3954 Seven-Segment Display 【状态标记】的更多相关文章

  1. ZOJ 3962 Seven Segment Display 16进制的八位数加n。求加的过程中所有的花费。显示[0,F]有相应花费。

    Seven Segment Display Time Limit: Seconds Memory Limit: KB A seven segment display, or seven segment ...

  2. ZOJ 3962 Seven Segment Display

    Seven Segment Display 思路: 经典数位dp 代码: #include<bits/stdc++.h> using namespace std; #define LL l ...

  3. zoj 3962 Seven Segment Display 数位dp

    非常好的一个题,可以比赛时想到的状态太奇葩,不方便转移,就一直没能AC. 思路:dp(i, j)表示已经考虑了前i位,前i位的和为j的贡献.如果当前的选择一直是最大的选择,那么就必须从0~下一位的最大 ...

  4. ZOJ 3962 Seven Segment Display(数位DP)题解

    题意:给一个16进制8位数,给定每个数字的贡献,问你贡献和. 思路:数位DP,想了很久用什么表示状态,看题解说用和就行,其他的都算是比较正常的数位DP. 代码: #include<iostrea ...

  5. ZOJ 3962 Seven Segment Display(数位DP)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3962 题目大意: 有t组数据. 给你一个n,和8位的十六进制数s ...

  6. 2017浙江省赛 E - Seven Segment Display ZOJ - 3962

    地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3962 题目: A seven segment display, or ...

  7. ZOJ 3962 E.Seven Segment Display / The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple E.数位dp

    Seven Segment Display Time Limit: 1 Second      Memory Limit: 65536 KB A seven segment display, or s ...

  8. (2017浙江省赛E)Seven Segment Display

    Seven Segment Display Time Limit: 2 Seconds      Memory Limit: 65536 KB A seven segment display, or ...

  9. Kattis - pizzahawaii 【状态标记】

    Kattis - pizzahawaii [状态标记] Description You are travelling in a foreign country. Although you are al ...

  10. ZOJ - 3962 - Seven Segment Display-17省赛-数位DP

    传送门:Seven Segment Display 题意:求一个给定区间每个数字的消耗值的和: 思路:数位DP,有点区间和的思想,还有就是这个十六进制,可以用%llx读,还是比较难的: 还有就是到最大 ...

随机推荐

  1. babel ---- presets字段设定转码规则

    presets字段设定转码规则,官方提供以下的规则集,你可以根据需要安装. # ES2015转码规则 $ npm install --save-dev babel-preset-es2015 # re ...

  2. SPOJ 7001 VLATTICE【莫比乌斯反演】

    题目链接: http://www.spoj.com/problems/VLATTICE/ 题意: 1≤x,y,z≤n,问有多少对(x,y,z)使得gcd(x,y,z)=1 分析: 欧拉搞不了了,我们用 ...

  3. Java中PO、BO、VO、DTO、POJO、DAO概念及其作用和项目实例图(转)

    PO(bean.entity等命名): Persistant Object持久对象,数据库表中的记录在java对象中的显示状态 最形象的理解就是一个PO就是数据库中的一条记录. 好处是可以把一条记录作 ...

  4. android TextView 设置字体大小

    package com.example.yanlei.yl4; import android.graphics.Color;import android.os.Bundle;import androi ...

  5. 小白学phoneGap《构建跨平台APP:phoneGap移动应用实战》连载一(PhoneGap中的API)

    之前本博连载过<构建跨平台APP:jQuery Mobile移动应用实战>一书.深受移动开发入门人员的喜爱. 从如今開始,连载它的孪生姐妹书phoneGap移动应用实战一书,希望以前是小白 ...

  6. jquery 的父子节点

    1.一级父节点 parent() n级父节点 parents(???). 2.一级子节点 children() n级子节点  用find(???)

  7. spring security开发步骤

    1.web.xml中加载spring ,spring security 2.spring security配置文件中配置好.... 3.自己写一个myFilter代替原有的FilterSecurity ...

  8. jquery中text(),html(),val()在取值上的区别

    1.html():读取和修改一个元素的HTML内容: 2.text():读取和修改一个元素的文本内容: 3.val():读取和修改一个表单元素的value字段值.

  9. 实战c++中的string系列--十六进制的字符串转为十六进制的整型(一般是颜色代码使用)

    非常久没有写关于string的博客了.由于写的差点儿相同了.可是近期又与string打交道,于是荷尔蒙上脑,小蝌蚪躁动. 在程序中,假设用到了颜色代码,一般都是十六进制的,即hex. 可是server ...

  10. PHP中的$_SERVER['PATH_INFO']

    PHP中的全局变量$_SERVER['PATH_INFO']是一个很有用的参数,众多的CMS系统在美化自己的URL的时候,都用到了这个参数. 对于下面这个网址: http://www.test.com ...