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 ...
随机推荐
- HibernateDaoSupport类的底层中hql操作使用
spring的ApplicationContex.xml 中配置 sql 查询方法: 加载数据源的两种方式: <!--方式一:使用 c3p0 连接池 加载数据源 --> <bean ...
- 运用模逆运算(同余方程)来解决Matlab课上的一道思考题
一道Matlab编程题 & 暴力解法 Matlab课上老师出了这样一道题: 一个篮子有K个鸡蛋: 2个2个拿剩1个: 3个3个全部拿完: 4个4个拿剩1: 5个5个拿剩4个: 6个6个拿剩3个 ...
- TCP/IP各种数据包结构体
下面这些TCP/IP数据包是我在进行Socket及Wipcap网络编程过程中曾经用到过的数据包结构体, 这些东西平时看起来不起眼,真正用到的时候就会觉得非常有用...... 以太帧头格式结构体,共14 ...
- 变色龙启动MAC时,错误信息“ntfs_fixup: magic doesn't match:”的解决办法
如下是变色龙启动的bdmesg,解决办法就是用mac的磁盘管理器,对ntfs分区进行检验修复.需要安装ntfs的驱动支持. 实在不行,就删除调整过大小的分区,重新用Windows的磁盘管理器重新分区. ...
- swift中使用sqlite3
import Foundation /** 1. 打开数据库 2. 如果没有数据表,需要首先创表 3. 数据操作 */ class SQLite { var db: COpaquePointer = ...
- 洛谷 P2846 光开关
https://www.luogu.org/problemnew/show/P2846 好多题解用线段树来写,然而分块不是更简单好些吗? 一个数组use记录这一块进行了多少次开关操作,两边单独计算,注 ...
- Codeforces Round #510 #A
http://codeforces.com/contest/1042/problem/A 题目大意就是: 现在公园里有n个长椅(要多长有多长),第i个长椅上有a[i]个人(泰山崩于前而不乱),现在又有 ...
- Kafka创建&查看topic,生产&消费指定topic消息
启动zookeeper和Kafka之后,进入kafka目录(安装/启动kafka参考前面一章:https://www.cnblogs.com/cici20166/p/9425613.html) 1.创 ...
- (转)UIPanGestureRecognizer
UIPanGestureRecognizer是UIGestureRecognizer类的一个扩展类,其扩展类有UITapGestureRecognizer,UIPinchGestureRecogniz ...
- 排序算法C语言实现——堆排序
/*堆排nlog(n)*//*堆排复杂度分析1.建堆((n*log(n))/2) 循环n/2次,每次调用HeapAdjust函数 HeapAdjust内部循环log(n)2.调整堆(((n ...