题目链接

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

题意

有一块 LED 灯

然后上面有七块灯管

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

给出一个标准表

然后 输入 一个表

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

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

这个表能够跟 标准表 相同

如果能 就输出 YES

不能 就输出 NO

思路

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

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

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

AC代码

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <ctype.h>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <climits>
  7. #include <ctime>
  8. #include <iostream>
  9. #include <algorithm>
  10. #include <deque>
  11. #include <vector>
  12. #include <queue>
  13. #include <string>
  14. #include <map>
  15. #include <stack>
  16. #include <set>
  17. #include <numeric>
  18. #include <sstream>
  19. #include <iomanip>
  20. #include <limits>
  21. #define CLR(a) memset(a, 0, sizeof(a))
  22. #define pb push_back
  23. using namespace std;
  24. typedef long long ll;
  25. typedef long double ld;
  26. typedef unsigned long long ull;
  27. typedef pair <int, int> pii;
  28. typedef pair <ll, ll> pll;
  29. typedef pair<string, int> psi;
  30. typedef pair<string, string> pss;
  31. const double PI = 3.14159265358979323846264338327;
  32. const double E = exp(1);
  33. const double eps = 1e-30;
  34. const int INF = 0x3f3f3f3f;
  35. const int maxn = 1e4 + 5;
  36. const int MOD = 1e9 + 7;
  37. int G[10][10];
  38. int v[10][10];
  39. struct Node
  40. {
  41. int n;
  42. int v[10];
  43. }q[10];
  44. bool comp(Node x, Node y)
  45. {
  46. return x.n < y.n;
  47. }
  48. void init()
  49. {
  50. CLR(G);
  51. G[1][1] = G[1][4] = G[1][5] = G[1][6] = G[1][7] = 1;
  52. G[2][3] = G[2][6] = 1;
  53. G[3][5] = G[3][6] = 1;
  54. G[4][1] = G[4][4] = G[4][5] = 1;
  55. G[5][2] = G[5][5] = 1;
  56. G[6][2] = 1;
  57. G[7][4] = G[7][5] = G[7][6] = G[7][7] = 1;
  58. G[9][5] = 1;
  59. }
  60. int main()
  61. {
  62. init();
  63. int t;
  64. scanf("%d", &t);
  65. while (t--)
  66. {
  67. CLR(v);
  68. int n;
  69. int arr[9];
  70. scanf("%d", &n);
  71. for (int i = 0; i < n; i++)
  72. {
  73. scanf("%d", &q[i].n);
  74. for (int j = 0; j < 7; j++)
  75. scanf("%1d", &q[i].v[j]);
  76. }
  77. sort(q, q + n, comp);
  78. map <int, int> vis[2];
  79. int num = 0;
  80. for (int i = 0; i < 7; i++)
  81. {
  82. num = 0;
  83. for (int j = 0; j < n; j++)
  84. {
  85. num = num * 2 + q[j].v[i];
  86. }
  87. vis[0][num]++;
  88. }
  89. for (int i = 1; i <= 7; i++)
  90. {
  91. num = 0;
  92. for (int j = 0; j < n; j++)
  93. {
  94. num = num * 2 + G[q[j].n][i];
  95. }
  96. vis[1][num]++;
  97. }
  98. map <int, int>::iterator it;
  99. int flag = 1;
  100. for (it = vis[0].begin(); it != vis[0].end(); it++)
  101. {
  102. if (vis[1][it->first] != it->second)
  103. {
  104. flag = 0;
  105. break;
  106. }
  107. }
  108. if (flag)
  109. printf("YES\n");
  110. else
  111. printf("NO\n");
  112. }
  113. }

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. 2017CCPC 哈尔滨 B

    这题没有考虑到m这个东西,所以就没有往二分答案的方向想 二分答案 check的时候,我们找的是大于等于x的数有多少个被加入到那个数组中.如果 >= m说明这个数可能是答案,否则就不是. 用尺取来 ...

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

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

  3. Light oj 1085 - All Possible Increasing Subsequences (简单dp + 离散化 + BIT)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1085 题意: 问你有多少个上升子序列. 思路: dp[i]表示以第i个数结尾的 ...

  4. awk在企业中最常用的语句

    awk最常用以及面试基本都会被问到的实例: A.统计日志中每个URL被访问的次数 cat access.log http://www.etiantian.org/1.html http://post. ...

  5. sed理论讲解、实战

    1.Sed是操作.过滤和转换文本内容的强大工具,常用功能有增删改查.过滤.取行. options(常用参数): -n:使用安静(silent)模式,在一般 sed 的用法中,所有来自 STDIN 的数 ...

  6. [CQOI2018] 社交网络

    题目背景 当今社会,在社交网络上看朋友的消息已经成为许多人生活的一部分.通常,一个用户在社交网络上发布一条消息(例如微博.状态.Tweet等) 后,他的好友们也可以看见这条消息,并可能转发.转发的消息 ...

  7. Codeforces 401D Roman and Numbers

    题目大意 Description 给定一个数 N(N<1018) , 求有多少个经过 N 重组的数是 M(M≤100) 的倍数. 注意: ①重组不能有前导零; ②重组的数相同, 则只能算一个数. ...

  8. Codeforces Beta Round #1 A. Theatre Square

    从今天開始.就要在Codeforces里有一个新的開始了,貌似任务非常重的说~~ Codeforces专题我将会记录全部通过的题目,事实上仅仅要通过的题目都是水题啊!. 题目大意: 依照要求计算须要多 ...

  9. spoj 1811 LCS - Longest Common Substring (后缀自己主动机)

    spoj 1811 LCS - Longest Common Substring 题意: 给出两个串S, T, 求最长公共子串. 限制: |S|, |T| <= 1e5 思路: dp O(n^2 ...

  10. ARP协议(1)什么是ARP协议

    这是最近在看<TCP/IP具体解释>系列书总结出来的,之后会陆续把其它协议部分分享出来. 我尽量以简单易读.易懂的方式呈现出来,可是,因为文笔和水平有限.有些地方或许存在描写叙述上的不足或 ...