题目链接

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. 如何获取MAC的进程数

    参考链接: https://www.cnblogs.com/watchdatalearn2012620/p/3182477.html https://segmentfault.com/q/101000 ...

  2. 转---派遣例程与IRP结构

    派遣例程与IRP结构   文章出处:http://www.cnblogs.com/zmlctt/p/3978124.html#commentform   提到派遣例程,必须理解IRP(I/O Requ ...

  3. VUE之命令行报错:Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead 解决办法

    Failed to compile. ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-5992 ...

  4. Java 经典笔试题

    这些题目对我的笔试帮助很大,有需要的朋友都可以来看看,在笔试中能遇到的题目基本上下面都会出现,虽然形式不同,当考察的基本的知识点还是相同的. 在分析中肯定有不足和谬误的地方还请大虾们能够给予及时的纠正 ...

  5. Database | SQL

    Basic of MySQL 创建数据库: mysql> create database xxj; Query OK, row affected (0.00 sec) 列举数据库: mysql& ...

  6. ajax跨域-springboot

    package com.xxxx.xx.service.configuration; import org.springframework.context.annotation.Bean; impor ...

  7. Mac item2 配色,大小写敏感及常用快捷键

    http://blog.csdn.net/lainegates/article/details/38313559 目录(?)[-] 配色 大小写敏感 快捷揵   item2是mac下非常好用的一款终端 ...

  8. Maven修改默认中央仓库

    其实Maven的默认仓库是可以修改的.比如使用阿里云的镜像地址等. 修改步骤: 1.打开{M2_HOME}/conf/settings.xml文件,找到mirrors节点,修改如下代码: <mi ...

  9. javascript --- 多重继承

    多重继承就是指,一个子对象中有不止一个父对象的继承模式. 想要实现她,还是非常简单的,而我们只需要延续属性拷贝的继承思路依次扩展对象即可,而对参数中所继承的对象没有限制. function multi ...

  10. CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'

    这个一般是证书设置的问题, 在build settings中找到 Code Signing->Code Signing Identity修改成有效的证书即可