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 ...
随机推荐
- PLAYGROUND 延时运行
PLAYGROUND 延时运行 由 王巍 (@ONEVCAT) 发布于 2015/09/16 从 WWDC 14 的 Keynote 上 Chris 的演示就能看出 Playground 异常强大,但 ...
- java面试宝典第四弹
动态代理 1. 什么是代理 我们大家都知道微商代理,简单地说就是代替厂家卖商品,厂家“委托”代理为其销售商品.关于微商代理,首先我们从他们那里买东西时通常不知道背后的厂家究竟是谁,也就是说,“委托者” ...
- HDU-1548-奇怪的电梯
这题的题意就是,如果在k层,该数的序号为k,则在k层上只能去k+a[k]层或者k-a[k],这样的话,就变成了一个单向联通图,对这个Dijkstra算法就可以了. #include <cstdi ...
- linux-MySQL基本指令-增删改查
常用指令 指令作用 指令 查看/查询 show,select,desc 创建 create 删除 drop,delete,truncate 切换/进入 use 添加记录 insert 查询类 查看数据 ...
- a标签中javascript和void
<body> <a href="javascript:;">点了无反应</a> <a href="javascript:void ...
- LeetCode(121) Best Time to Buy and Sell Stock
题目 Say you have an array for which the ith element is the price of a given stock on day i. If you we ...
- Verilog学习笔记基本语法篇(八)········ 结构说明语句
Verilog中的任何过程都可以属于以下四种结构的说明语句; 1) initial; 2) always; 3) task; 4) function; 1) initial说明语句: 一个程序 ...
- Java中IO流讲解(一)
一.概念 IO流用来处理设备之间的数据传输 Java对数据的操作是通过流的方式 Java用于操作流的类都在IO包中 流按流向分为两种:输入流,输出流 流按操作类型分为两种: 字节流 : 字节流可以操作 ...
- Python开发:模块
在前面的几个章节中我们脚本上是用 python 解释器来编程,如果你从 Python 解释器退出再进入,那么你定义的所有的方法和变量就都消失了. 为此 Python 提供了一个办法,把这些定义存放在文 ...
- 【01】CSS规范
[01]CSS规范 []https://drafts.csswg.org/indexes/(下图) https://www.w3.org/TR/2011/REC-CSS2-20110607/ ...