原题地址: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. Jarvis OJ-Level3-x64

    linux64位ROP技术 #!/usr/bin/env python from pwn import * elf = ELF('level3_x64') Io = remote('pwn2.jarv ...

  2. 关于windows server 2003 IE 不能访问 https问题

    https://xx.wosign.com/FAQ/Windows2003_server_sha256_support_problem.html 补丁地址: https://xx.wosign.com ...

  3. ios多线程NSThread

    1.简介: 1.1 iOS有三种多线程编程的技术,分别是: 1..NSThread 2.Cocoa NSOperation (iOS多线程编程之NSOperation和NSOperationQueue ...

  4. iOS 静态库,动态库与 Framework

    iOS 静态库,动态库与 Framework     静态库与动态库的区别 首先来看什么是库,库(Library)说白了就是一段编译好的二进制代码,加上头文件就可以供别人使用. 什么时候我们会用到库呢 ...

  5. input标签内容改变触发的事件

    原生方法 onchange事件 <input type="text" onchange="onc(this)"> function onc(data ...

  6. POJ:2406-Power Strings(寻找字符串循环节)

    Power Strings Time Limit: 3000MS Memory Limit: 65536K Description Given two strings a and b we defin ...

  7. 引用类型(JavaScript第5章)

    引用类型的值(对象)是引用类型的一个实例.在ECMScript中,引用类型是一种数据结构,用于将数据和功能组织在一起. 一.Object类型 创建Object实例的方式有两种.第一种是使用new操作符 ...

  8. BRVAH(让RecyclerView变得更高效) (3)

    本文来自网易云社区 作者:吴思博 3 实现列表加载动画效果    3.1默认动画 我们只需将自建的 adapter 继承它对应满足需求的 Adapter,然后在 Activity 中实例化,通过ope ...

  9. 设置Putty 字体 颜色 全屏

    效果 1.   字体 2.全屏 3. 颜色 Window->Colours->Default Foreground->Modify设置(我喜欢绿色设置:R:0 G:255 B:0) ...

  10. 【LeetCode】Broken Calculator(坏了的计算器)

    这道题是LeetCode里的第991道题. 题目描述: 在显示着数字的坏计算器上,我们可以执行以下两种操作: 双倍(Double):将显示屏上的数字乘 2: 递减(Decrement):将显示屏上的数 ...