原题地址: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 傻逼暴力的更多相关文章

  1. codeforces Gym 100286J Javanese Cryptoanalysis (二染色)

    每一单词相邻两个字母,不能同时为元音或者辅音... 各种姿势都可以过:7个for,dp,黑白染色,dfs,并查集.... 最主要的思路就是相邻字母连边,把元音和辅音看成两个集合,那么有连边的两个字母一 ...

  2. Codeforces Gym 100338I TV Show 傻逼DFS,傻逼题

    Problem I. TV ShowTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  3. Codeforces Gym 100803F There is No Alternative 暴力Kruskal

    There is No Alternative 题目连接: http://codeforces.com/gym/100803/attachments Description ICPC (Isles o ...

  4. Codeforces Gym 100342C Problem C. Painting Cottages 暴力

    Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...

  5. 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 ...

  6. Codeforces Gym 100203G G - Good elements 标记暴力

    G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  7. Codeforces Gym 100650D Queens, Knights and Pawns 暴力

    Problem D: Queens, Knights and PawnsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu ...

  8. Codeforces gym 100685 A. Ariel 暴力

    A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...

  9. Codeforces Gym 100570 E. Palindrome Query Manacher

    E. Palindrome QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100570/pro ...

随机推荐

  1. _IO_FILE

    hctf2017的babyprintf解法是house of orange,深入学习了一下,牵扯出许多知识,这里先进行第一步:_IO_FILE结构 0x00 _IO_FILE glibc-2.2.1\ ...

  2. pwntools学习

    0x00 数据处理 主要是对整数进行打包,就是转换成二进制的形式,比如转换成地址.p是打包,u是解包 32位:p32,u32 64位:p64,u64 0x01 汇编与反汇编 1.asm 进行汇编,使用 ...

  3. java集合测试类等

    package demo.mytest; import java.lang.ref.SoftReference;import java.lang.ref.WeakReference;import ja ...

  4. UIScreen, UIWindow

    模仿书上或网上的例子,每次最开始就是 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: ...

  5. 【dp】bzoj1613: [Usaco2008 Jan]Running贝茜的晨练计划

    还记得这是以前看上去的不可做题…… Description 奶牛们打算通过锻炼来培养自己的运动细胞,作为其中的一员,贝茜选择的运动方式是每天进行N(1<=N<=10,000)分钟的晨跑.在 ...

  6. Android Studio问题记录

    1>Android Studio中module是什么,? 答:Android Studio是基于intellij,跟eclipse不太一样.对应关系如下: intellij的project -- ...

  7. python动态添加属性和方法

    ---恢复内容开始--- python动态添加属性: class Person(object): def __init__(self,newName,newAge): self.name = newN ...

  8. shell-code-4-运算符

    #1. shell 基本运算符有:算数.关系.布尔.字符串.文件测试运算符#2. 原生bash不支持简单的数学运算,可使用awk和expr(最常用)echo `expr 1 + 2`# 反引号:表达式 ...

  9. SVM 支持向量机算法介绍

    转自:https://zhuanlan.zhihu.com/p/21932911?refer=baina 参考:http://www.cnblogs.com/LeftNotEasy/archive/2 ...

  10. C++ STL容器底层机制

    1.vector容器 vector的数据安排以及操作方式,与array非常相似.两者的唯一区别在于空间的运用的灵活性.array是静态空间,一旦配置了就不能改变.vector是动态空间,随着元素的加入 ...