Password UVA
来源:互联网 发布:网络文化节上的讲话 编辑:程序博客网 时间:2024/06/05 06:48
题目传送门
题意;给你两个6行5列的密码矩阵,找出满足下列条件的“密码”:密码中的每一个字母都在两个矩阵的对应列中出现,求字典序第k大的的密码,如果没有输出NO。
题意:直接暴力瞎搞一下就好了。
#include <algorithm>#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <list>#include <map>#include <queue>#include <set>#include <stack>#include <string>#include <vector>#define MAXN 10#define MAXE 400#define INF 100000000#define MOD 10001#define LL long long#define pi 3.14159using namespace std;string matrix1[MAXN];string matrix2[MAXN];set<char> Set[MAXN];int main() { std::ios::sync_with_stdio(false); int T; cin >> T; for (int kase = 1; kase <= T; ++kase) { int k; for (int i = 0; i < MAXN; ++i) { Set[i].clear(); } cin >> k; for (int i = 0; i < 6; ++i) { cin >> matrix1[i]; } for (int i = 0; i < 6; ++i) { cin >> matrix2[i]; } set<char> s; for (int i = 0; i < 5; ++i) { s.clear(); for (int j = 0; j < 6; ++j) { s.insert(matrix1[j][i]); } for (int j = 0; j < 6; ++j) { if (s.count(matrix2[j][i])) { Set[i].insert(matrix2[j][i]); } } } if (Set[0].size() * Set[1].size() * Set[2].size() * Set[3].size() * Set[4].size() < k) { cout << "NO\n"; } else { int num1 = (int) Set[1].size(); int num2 = (int) Set[2].size(); int num3 = (int) Set[3].size(); int num4 = (int) Set[4].size(); vector<int> vec; int pos = k / (num1 * num2 * num3 * num4); k %= (num1 * num2 * num3 * num4); if (k == 0) { vec.push_back(pos - 1); k = num1 * num2 * num3 * num4; } else { vec.push_back(pos); } pos = k / (num2 * num3 * num4); k %= (num2 * num3 * num4); if (k == 0) { vec.push_back(pos - 1); k = num2 * num3 * num4; } else { vec.push_back(pos); } pos = k / (num3 * num4); k %= (num3 * num4); if (k == 0) { vec.push_back(pos - 1); k = num3 * num4; } else { vec.push_back(pos); } pos = k / num4; k %= num4; if (k == 0) { vec.push_back(pos - 1); k = num4; } else { vec.push_back(pos); } pos = k; vec.push_back(pos - 1); string str = "\0"; for (int i = 0; i < 5; ++i) { int ans = 0; for (set<char>::iterator it = Set[i].begin(); it != Set[i].end(); ++it) { if (ans == vec[i]) { str += *it; break; } ans++; } } cout << str << endl; } } return 0;}/* 3 1 AYGSU DOMRA CPFAS XBODG WDYPK PRXWO CBOPT DOSBG GTRAR APMMS WSXNU EFGHI 5 AYGSU DOMRA CPFAS XBODG WDYPK PRXWO CBOPT DOSBG GTRAR APMMS WSXNU EFGHI 64 FGHIJ EFGHI DEFGH CDEFG BCDEF ABCDE WBXDY UWYXZ XXZFG YYFYH EZWZI ZGHIJ */
阅读全文
0 0
- Password UVA
- Password UVA
- Password UVA
- Password UVA
- password search uva 902
- UVA 1262 - Password
- UVA 1262 Password
- UVA 1262 - Password
- UVa 902 - Password Search
- uva 1262(Password)
- UVA 1262(p323p)----Password
- UVA 1262 Password
- uva 1262 Password
- UVa 1262 password
- UVa 1262 Password
- UVA 1262 Password (水题)
- UVA 1262 Password 暴力枚举
- UVA 902 Password Search (字符串)
- grep常用参数说明
- git常用命令——对我很实用
- spring boot项目实战:swagger2在线文档
- 用类描述计算机中CPU的速度和硬盘的容量
- 解决scrollView与recyclerView的滑动嵌套问题
- Password UVA
- sqlserver镜像搭建
- Hadoop
- 爬虫基于ADSL动态获取ip
- 在centeros搭建workpress
- MySQL分区详解
- HTTP请求和HTTP响应
- tcp udp的区别
- 【English】《赖世雄音标》学习小结