| Task: | Decrypt |
| Sender: | :] |
| Submission time: | 2016-09-06 17:33:43 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | ACCEPTED | 0.10 s | details |
| #3 | ACCEPTED | 0.05 s | details |
| #4 | ACCEPTED | 0.05 s | details |
| #5 | ACCEPTED | 0.06 s | details |
| #6 | ACCEPTED | 0.06 s | details |
| #7 | ACCEPTED | 0.05 s | details |
| #8 | ACCEPTED | 0.05 s | details |
| #9 | ACCEPTED | 0.06 s | details |
| #10 | ACCEPTED | 0.05 s | details |
| #11 | ACCEPTED | 0.06 s | details |
| #12 | ACCEPTED | 0.05 s | details |
| #13 | ACCEPTED | 0.06 s | details |
| #14 | ACCEPTED | 0.06 s | details |
| #15 | ACCEPTED | 0.06 s | details |
| #16 | ACCEPTED | 0.05 s | details |
| #17 | ACCEPTED | 0.05 s | details |
| #18 | ACCEPTED | 0.05 s | details |
| #19 | ACCEPTED | 0.06 s | details |
| #20 | ACCEPTED | 0.05 s | details |
| #21 | ACCEPTED | 0.05 s | details |
| #22 | ACCEPTED | 0.05 s | details |
| #23 | ACCEPTED | 0.06 s | details |
| #24 | ACCEPTED | 0.05 s | details |
| #25 | ACCEPTED | 0.06 s | details |
| #26 | ACCEPTED | 0.05 s | details |
| #27 | ACCEPTED | 0.06 s | details |
| #28 | ACCEPTED | 0.06 s | details |
| #29 | ACCEPTED | 0.05 s | details |
| #30 | ACCEPTED | 0.05 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
int per[26],res[26];
int tmp[26];
void mul1() {
for (int i=0;i<26;i++) {
if (per[i]==-1 || per[per[i]]==-1) tmp[i]=-1;
else tmp[i]=per[per[i]];
}
for (int i=0;i<26;i++) per[i]=tmp[i];
}
void mul2() {
for (int i=0;i<26;i++) {
if (per[i]==-1) tmp[i]=-1;
else tmp[i]=res[per[i]];
}
for (int i=0;i<26;i++) res[i]=tmp[i];
}
void pot(int k) {
for (int i=0;i<26;i++) res[i]=i;
while (k) {
if (k&1) mul2();
mul1();
k>>=1;
}
}
int main() {
for (int i=0;i<26;i++) per[i]=-1;
string f,s;
int k;
cin>>f>>k>>s;
for (int i=0;i<26;i++) {
if (per[f[i]-'a']>=0) per[f[i]-'a']=-2;
if (per[f[i]-'a']==-1) per[f[i]-'a']=i;
}
for (int i=0;i<26;i++) per[i]=max(per[i],-1);
pot(k);
for (char c : s) {
if (res[c-'a']==-1) {
cout<<"impossible\n";
return 0;
}
}
for (char c : s) {
cout<<(char)(res[c-'a']+'a');
}
cout<<"\n";
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| egkpmqujbxhiatorvznwcfynds 564... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 2
Verdict: ACCEPTED
| input |
|---|
| pdabvolaobzbaaisrntdtwluwf 2 oooooooooooooooooooooooooooooo... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 3
Verdict: ACCEPTED
| input |
|---|
| xtaoqlsjkezrcvinwfmbyhdgpu 872... |
| correct output |
|---|
| mmm |
| user output |
|---|
| mmm |
Test 4
Verdict: ACCEPTED
| input |
|---|
| wlcpatbrudxhofijgskqgevymz 1 joojjojjjoojjjjoojjojoojojoojj... |
| correct output |
|---|
| pmmppmpppmmppppmmppmpmmpmpmmpp... |
| user output |
|---|
| pmmppmpppmmppppmmppmpmmpmpmmpp... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| tjyivkaulcjnehvtilatxjxmxd 300... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 6
Verdict: ACCEPTED
| input |
|---|
| tonbvkcqilfjghszxpwmdureay 2 nnv |
| correct output |
|---|
| ggx |
| user output |
|---|
| ggx |
Test 7
Verdict: ACCEPTED
| input |
|---|
| edmxaqolzisvnrfkcgwehbtjpu 179... |
| correct output |
|---|
| oooooooooooooooooooooooooooooo... |
| user output |
|---|
| oooooooooooooooooooooooooooooo... |
Test 8
Verdict: ACCEPTED
| input |
|---|
| hrygatmxebcusinbdplunukuai 1 i |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 9
Verdict: ACCEPTED
| input |
|---|
| nsuftdzbmkqepgihlyxrvwajoc 724... |
| correct output |
|---|
| offfofofofofoffooofofooofffffo... |
| user output |
|---|
| offfofofofofoffooofofooofffffo... |
Test 10
Verdict: ACCEPTED
| input |
|---|
| kbybextsniougrdmqpwfahzlcv 2 stlooyhhdfzpspsospvhdpedouqsyr... |
| correct output |
|---|
| vmfaayzzkgsnvnvavnwzknekaxqvyi... |
| user output |
|---|
| vmfaayzzkgsnvnvavnwzknekaxqvyi... |
Test 11
Verdict: ACCEPTED
| input |
|---|
| dugyojozcpjlwxepebzhfkqlzc 801... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 12
Verdict: ACCEPTED
| input |
|---|
| kibphqeygnmsdvawzrfcuotxjl 2 ggggggggggggggggggggggggggg |
| correct output |
|---|
| bbbbbbbbbbbbbbbbbbbbbbbbbbb |
| user output |
|---|
| bbbbbbbbbbbbbbbbbbbbbbbbbbb |
Test 13
Verdict: ACCEPTED
| input |
|---|
| pstlbyjnovmekdqzrhwxwgcfai 315... |
| correct output |
|---|
| mmm |
| user output |
|---|
| mmm |
Test 14
Verdict: ACCEPTED
| input |
|---|
| uukjvcscfohyvqomdfdlysnuoe 2 eheeheheeheheeheeheeeehhhheehh... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 15
Verdict: ACCEPTED
| input |
|---|
| pkwsxbvdgmjutiyfqrzhealnoc 822... |
| correct output |
|---|
| hbkxkmhinhmwhwthbmhutgnkgoywho... |
| user output |
|---|
| hbkxkmhinhmwhwthbmhutgnkgoywho... |
Test 16
Verdict: ACCEPTED
| input |
|---|
| yqxvbohrlifmzdtwgejpcanuse 1 fl |
| correct output |
|---|
| ki |
| user output |
|---|
| ki |
Test 17
Verdict: ACCEPTED
| input |
|---|
| gauouzffisuxjtuufqdappivxv 205... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 18
Verdict: ACCEPTED
| input |
|---|
| ovqzprxiluehkndsmtyafbwgjc 2 oo |
| correct output |
|---|
| tt |
| user output |
|---|
| tt |
Test 19
Verdict: ACCEPTED
| input |
|---|
| goqbyzivahrxnjwtdjluepsmkf 701... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 20
Verdict: ACCEPTED
| input |
|---|
| vlovrwpvkfbotybcmcbixsbfly 2 jutqryuhbjjqvbpaeqoyduqneybsli... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 21
Verdict: ACCEPTED
| input |
|---|
| eawzhgmusltxjypkirbcfndovq 262... |
| correct output |
|---|
| a |
| user output |
|---|
| a |
Test 22
Verdict: ACCEPTED
| input |
|---|
| kqdpgnevpuyahrjclfzwsomxti 2 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkk... |
| correct output |
|---|
| llllllllllllllllllllllllllllll... |
| user output |
|---|
| llllllllllllllllllllllllllllll... |
Test 23
Verdict: ACCEPTED
| input |
|---|
| xwfgenquyctxdvmptcrdhvcxwq 778... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 24
Verdict: ACCEPTED
| input |
|---|
| sucejvkmrhtobzxglapdnifqwy 1 qddqqqqqdqqqqddddqqdqqqdqdqddq... |
| correct output |
|---|
| xttxxxxxtxxxxttttxxtxxxtxtxttx... |
| user output |
|---|
| xttxxxxxtxxxxttttxxtxxxtxtxttx... |
Test 25
Verdict: ACCEPTED
| input |
|---|
| pzukghijmcsalwnvoydxftbreu 413... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 26
Verdict: ACCEPTED
| input |
|---|
| adlsmbfijwmdcwglhgnvaooybu 1 aio |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 27
Verdict: ACCEPTED
| input |
|---|
| zqynskaxvcljewmfditourgpbh 756... |
| correct output |
|---|
| oooooooooooooooooooooooooooooo... |
| user output |
|---|
| oooooooooooooooooooooooooooooo... |
Test 28
Verdict: ACCEPTED
| input |
|---|
| truzcldhkeqspoabgyvmjwnfik 1 zz |
| correct output |
|---|
| dd |
| user output |
|---|
| dd |
Test 29
Verdict: ACCEPTED
| input |
|---|
| upfasuzkjuwhrnajgmitgysvil 467... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 30
Verdict: ACCEPTED
| input |
|---|
| bemlodzqjgixuksatvyfcpnhrw 1 zdaaskooqkzzifuzspzayokihzxqhf... |
| correct output |
|---|
| gfpponeehnggktmgovgpsenkxglhxt... |
| user output |
|---|
| gfpponeehnggktmgovgpsenkxglhxt... |
