# Codeforces Gym 100286J Javanese cryptoanalysis

Source: Internet
Author: User

Each word is adjacent to two letters, cannot be a vowel or consonant at the same time, must have five vowels ...

Various poses can be over: 7 FOR,DP, black and white stained, DFS, and check ....

The main idea is that the adjacent letter is connected to the edge

See how slow str = str + STR2

`#include <bits/stdc++.h>using namespacestd;#definePB push_backintcolor[ -];intg[ -][ -];Const intMAXN = 1e5+5;CharS[MAXN];BOOLvis[ -];Charmp[ -];BOOLBipartite (intu) {     for(intv =0; V < -; v++)if(G[u][v]) {if(Color[v] = = Color[u])return false; if(!Color[v]) {Color[v]=3-Color[u]; if(!bipartite (v))return false; }    }    return true;}Chartab[5] = {'A','E','I','O','U'};intTsz =0, TSZ2 =0;Chartab2[ +]  = {'B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'};vector<string>Word;vector<int> bcc[ -][2];intbcnt;BOOLDfsintDintCurints) {    if(d = =bcnt) {        if(cur = =5){             for(inti =0; i < bcnt; i++) {vector<int> &v = bcc[i][(s>>i) &1];  for(intj =0; J < V.size (); J + +) {Mp[v[j]]= tab[tsz++]; }            }            return true; }        return false; }    if(Dfs (d+1, cur+bcc[d][0].size (), s) | | DFS (d+1, cur+bcc[d][1].size (), s| (1&LT;&LT;D)))return true; return false;}intMain () {//freopen ("In.txt", "R", stdin);Freopen ("javanese.in","R", stdin); Freopen ("Javanese.out","W", stdout);  while(~SCANF ("%s", s)) {Word.        PB (s);  for(inti =1; S[i]; i++){            intU = s[i]-'A', V = s[i-1] -'A'; G[U][V]= G[v][u] =1; }    }     for(inti =0; I < -; i++)if(!Color[i]) {Color[i]=1; if(!bipartite (i)) {Puts ("Impossible");return 0; }  for(inti =0; I < -; i++)if(color[i]&&!Vis[i]) {Vis[i]=true; Bcc[bcnt][color[i]-1].        PB (i); } bcnt++; }    if(!dfs (0,0,0) {puts ("Impossible"); }    Else {         for(inti =0; I < -; i++)if(!mp[i]) mp[i] = tab2[tsz2++];  for(intj =0; J < Word.size (); J + +){            if(j) Putchar (' '); string& str =Word[j];  for(inti =0; I < str.size (); i++){                if('A'<=str[i]&&str[i]<='Z') Putchar (Mp[str[i]-'A']); ElsePutchar (Str[i]); }} putchar ('\ n'); }    return 0;}`

Codeforces Gym 100286J Javanese cryptoanalysis

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.