Codeforces Gym 100286J Javanese Cryptoanalysis 傻逼暴力
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-european-regional-contest-neerc-08-en.pdf
此题题意是给你一个单对单密文,让你还原为原文,原文有个性质是,每个单词都是元音和辅音交替组成。
做法是直接5重for,暴力枚举AEIOU分别对应的字母,然后检查,然后输出
详见代码:
//#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include <string.h> #define MAX_A 26
#define MAX_N 100005
using namespace std; vector<int> G[MAX_A]; string str[MAX_N];
int n = ;
string s; bool g[MAX_A][MAX_A]; int vo[MAX_A];
int tot = ;
bool flag = ; int main() {
ifstream cin("javanese.in");
ofstream cout("javanese.out");
cin.sync_with_stdio(false);
for (int i = ; i < ; i++) {
if (i != && i != 'E' - 'A' && i != 'I' - 'A' && i != 'O' - 'A' && i != 'U' - 'A')
vo[tot++] = i;
}
while (cin >> s) {
if (s == "*")break;
str[n++] = s;
for (int i = ; i + < s.length(); i++) {
int u = s[i] - 'A', v = s[i + ] - 'A';
if (u == v)flag = false;
if (g[u][v])continue;
G[s[i] - 'A'].push_back(s[i + ] - 'A');
g[u][v] = ;
}
if (flag == ) {
cout << "impossible" << endl;
return ;
}
}
int a[]; for (a[] = ; a[] < ; a[]++)
for (a[] = a[] + ; a[] < ; a[]++)
for (a[] = a[] + ; a[] < ; a[]++)
for (a[] = a[] + ; a[] < ; a[]++)
for (a[] = a[] + ; a[] < ; a[]++) {
int f[];
memset(f, -, sizeof(f));
int tmp = ;
bool t = ;
for (int i = ; i < && t; i++)
for (int j = ; j < && t; j++)if (g[a[i]][a[j]])t = ;
if (t == )continue;
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
if (g[i][j] && i != a[] && i != a[] && i != a[] && i != a[] && i != a[] &&
j != a[] && j != a[] && j != a[] && j != a[] && j != a[])
t = ;
if (t == )continue;
for (int i = ; i < n; i++, cout << " ")
for (int j = ; j < str[i].length(); j++) {
int u = str[i][j] - 'A';
if (f[u] != -) {
cout << (char)(f[u] + 'A');
continue;
}
if (u == a[])f[u] = 'A' - 'A';
else if (u == a[])f[u] = 'E' - 'A';
else if (u == a[])f[u] = 'I' - 'A';
else if (u == a[])f[u] = 'O' - 'A';
else if (u == a[])f[u] = 'U' - 'A';
else f[u] = vo[tmp++];
cout << (char)(f[u] + 'A');
}
cout << endl;
return ;
}
cout << "impossible" << endl;
return ;
}
Codeforces Gym 100286J Javanese Cryptoanalysis 傻逼暴力的更多相关文章
- codeforces Gym 100286J Javanese Cryptoanalysis (二染色)
每一单词相邻两个字母,不能同时为元音或者辅音... 各种姿势都可以过:7个for,dp,黑白染色,dfs,并查集.... 最主要的思路就是相邻字母连边,把元音和辅音看成两个集合,那么有连边的两个字母一 ...
- Codeforces Gym 100338I TV Show 傻逼DFS,傻逼题
Problem I. TV ShowTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...
- Codeforces Gym 100803F There is No Alternative 暴力Kruskal
There is No Alternative 题目连接: http://codeforces.com/gym/100803/attachments Description ICPC (Isles o ...
- Codeforces Gym 100342C Problem C. Painting Cottages 暴力
Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...
- Codeforces Gym 100513I I. Sale in GameStore 暴力
I. Sale in GameStore Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/p ...
- Codeforces Gym 100203G G - Good elements 标记暴力
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- Codeforces Gym 100650D Queens, Knights and Pawns 暴力
Problem D: Queens, Knights and PawnsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu ...
- Codeforces gym 100685 A. Ariel 暴力
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...
- Codeforces Gym 100570 E. Palindrome Query Manacher
E. Palindrome QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100570/pro ...
随机推荐
- 洛谷 P2668 斗地主
毒瘤题目,搞了三天-- 也没什么好讲的,就是纯搜索,先搜顺子,再搜其他的,最后单张牌和对子的时候,就不要搜索了,直接枚举,不然会T飞掉多么痛的领悟-- 主要还是靠码力 #include<iost ...
- POJ 3080 Blue Jeans、POJ 3461 Oulipo——KMP应用
题目:POJ3080 http://poj.org/problem?id=3080 题意:对于输入的文本串,输出最长的公共子串,如果长度相同,输出字典序最小的. 这题数据量很小,用暴力也是16ms,用 ...
- Life is short.,You need Python
真棒Python https://awesome-python.com/ 精选的Python框架,库,软件和资源的精选列表. 灵感来自awesome-php. 真棒Python 管理员面板 算法和设 ...
- spring,spring mvc,mybatis 常用注解
文章来源:https://www.cnblogs.com/hello-tl/p/9209063.html 0.在spring,soring mvc, mybistis 中的常用注解有一下 <! ...
- 《嵌入式linux应用程序开发标准教程》笔记——6.文件IO编程
前段时间看APUE,确实比较详细,不过过于详细了,当成工具书倒是比较合适,还是读一读这种培训机构的书籍,进度会比较快,遇到问题时再回去翻翻APUE,这样的效率可能更高一些. <嵌入式linux应 ...
- leetcode-2-basic
解题思路: 题目本身挺简单的,考虑用set,判断每个单词的字母是不是属于同一个集合.需要注意的是:1)set的构造方法:2)单词可能是大小写混合的,不一定只是首字母大写: 3)break是跳出循环=. ...
- js 获取json对象的Key、value
<script type="text/javascript"> getJson('age'); function getJson(key){ var jsonObj={ ...
- Android开发调试无法连接到夜神模拟器的解决方法
Android开发调试无法连接到夜神模拟器的解决方法: 一般原因是adb的版本不一致造成的!!!!!换成一样的就可以了. 在网上看到的方法,特记录下来: 1.任务管理器里看下,adb.exe以及nox ...
- Linux rm删除
将 test1子目录及子目录中所有档案删除 命令: rm -r test1 rm -rf test2命令会将 test2 子目录及子目录中所有档案删除,并且不用一一确认 命令: rm -rf tes ...
- CSU-1336: Interesting Calculator,最短路思想!
1336: Interesting Calculator 这道题被LZQ抢了一血,于是去读题发现题意不难,纯广搜结果写的一塌糊涂. 题意:给你两个数x,y.由x每次可以经过一系列操作变换,每个变换都有 ...