| Task: | Decrypt |
| Sender: | OOliOO_slayer |
| Submission time: | 2016-09-06 19:21:44 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | ACCEPTED | 0.05 s | details |
| #3 | WRONG ANSWER | 0.05 s | details |
| #4 | WRONG ANSWER | 0.05 s | details |
| #5 | ACCEPTED | 0.06 s | details |
| #6 | WRONG ANSWER | 0.06 s | details |
| #7 | WRONG ANSWER | 0.05 s | details |
| #8 | ACCEPTED | 0.06 s | details |
| #9 | WRONG ANSWER | 0.05 s | details |
| #10 | WRONG ANSWER | 0.06 s | details |
| #11 | ACCEPTED | 0.05 s | details |
| #12 | WRONG ANSWER | 0.03 s | details |
| #13 | WRONG ANSWER | 0.06 s | details |
| #14 | ACCEPTED | 0.06 s | details |
| #15 | WRONG ANSWER | 0.05 s | details |
| #16 | WRONG ANSWER | 0.05 s | details |
| #17 | ACCEPTED | 0.06 s | details |
| #18 | WRONG ANSWER | 0.05 s | details |
| #19 | ACCEPTED | 0.06 s | details |
| #20 | ACCEPTED | 0.05 s | details |
| #21 | WRONG ANSWER | 0.05 s | details |
| #22 | WRONG ANSWER | 0.05 s | details |
| #23 | ACCEPTED | 0.05 s | details |
| #24 | WRONG ANSWER | 0.06 s | details |
| #25 | ACCEPTED | 0.04 s | details |
| #26 | ACCEPTED | 0.06 s | details |
| #27 | WRONG ANSWER | 0.06 s | details |
| #28 | WRONG ANSWER | 0.06 s | details |
| #29 | ACCEPTED | 0.05 s | details |
| #30 | WRONG ANSWER | 0.05 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:23:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < f.size(); i++){
^
input/code.cpp:30:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < s.size(); i++){
^
input/code.cpp:76:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < cycle.size(); i++){
^Code
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;
typedef long long LL;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
string f; cin >> f;
LL k; cin >> k;
string s; cin >> s;
map<char,int> counts;
for(int i = 0; i < f.size(); i++){
counts[f[i]]++;
}
for(auto keyvalue : counts){
int c = keyvalue.first;
int number = keyvalue.second;
if(number > 1){
for(int i = 0; i < s.size(); i++){
if(s[i] == c){
cout << "impossible" << endl;
return 0;
}
}
}
}
set<char> S(f.begin(), f.end());
if(S.size() != 26){
cout << "impossible" << endl;
return 0;
}
vector<int> p(26);
for(int i = 0; i < 26; i++){
p[i] = f[i] - 'a';
}
vector<int> p_inv(26);
for(int i = 0; i < 26; i++){
p_inv[p[i]] = i;
}
//for(auto x : p) cout << x << " "; cout << endl;
//for(auto x : p_inv) cout << x << " "; cout << endl;
vector<bool> used(26);
vector<vector<LL> > cycles;
for(int i = 0; i < 26; i++){
vector<LL> cycle;
int cur = i;
if(used[cur]) continue;
while(!used[cur]){
used[cur] = true;
cycle.push_back(cur);
cur = p_inv[cur];
}
cycles.push_back(cycle);
//for(auto x : cycle) cout << x << " "; cout << endl;
}
vector<int> pk;
for(int i = 0; i < 26; i++) pk.push_back(i);
for(auto cycle : cycles){
LL iters = k % cycle.size();
for(int i = 0; i < cycle.size(); i++){
pk[cycle[i]] = cycle[(i+iters) % cycle.size()];
}
}
for(auto x : pk) cout << x << " "; cout << endl;
for(char c : s){
cout << (char)(pk[c - 'a'] + 'a');
}
cout << endl;
}
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: WRONG ANSWER
| input |
|---|
| xtaoqlsjkezrcvinwfmbyhdgpu 872... |
| correct output |
|---|
| mmm |
| user output |
|---|
| 18 19 6 24 10 5 2 14 13 8 21 1... |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| wlcpatbrudxhofijgskqgevymz 1 joojjojjjoojjjjoojjojoojojoojj... |
| correct output |
|---|
| pmmppmpppmmppppmmppmpmmpmpmmpp... |
| user output |
|---|
| impossible |
Test 5
Verdict: ACCEPTED
| input |
|---|
| tjyivkaulcjnehvtilatxjxmxd 300... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| tonbvkcqilfjghszxpwmdureay 2 nnv |
| correct output |
|---|
| ggx |
| user output |
|---|
| 25 20 12 21 16 5 19 2 8 9 10 1... |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| edmxaqolzisvnrfkcgwehbtjpu 179... |
| correct output |
|---|
| oooooooooooooooooooooooooooooo... |
| user output |
|---|
| impossible |
Test 8
Verdict: ACCEPTED
| input |
|---|
| hrygatmxebcusinbdplunukuai 1 i |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| nsuftdzbmkqepgihlyxrvwajoc 724... |
| correct output |
|---|
| offfofofofofoffooofofooofffffo... |
| user output |
|---|
| 25 9 22 5 24 3 20 23 7 11 4 17... |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| kbybextsniougrdmqpwfahzlcv 2 stlooyhhdfzpspsospvhdpedouqsyr... |
| correct output |
|---|
| vmfaayzzkgsnvnvavnwzknekaxqvyi... |
| user output |
|---|
| impossible |
Test 11
Verdict: ACCEPTED
| input |
|---|
| dugyojozcpjlwxepebzhfkqlzc 801... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| kibphqeygnmsdvawzrfcuotxjl 2 ggggggggggggggggggggggggggg |
| correct output |
|---|
| bbbbbbbbbbbbbbbbbbbbbbbbbbb |
| user output |
|---|
| 21 19 22 10 8 11 1 6 2 7 14 16... |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| pstlbyjnovmekdqzrhwxwgcfai 315... |
| correct output |
|---|
| mmm |
| user output |
|---|
| impossible |
Test 14
Verdict: ACCEPTED
| input |
|---|
| uukjvcscfohyvqomdfdlysnuoe 2 eheeheheeheheeheeheeeehhhheehh... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| pkwsxbvdgmjutiyfqrzhealnoc 822... |
| correct output |
|---|
| hbkxkmhinhmwhwthbmhutgnkgoywho... |
| user output |
|---|
| 20 13 9 5 3 23 22 15 2 6 8 19 ... |
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| yqxvbohrlifmzdtwgejpcanuse 1 fl |
| correct output |
|---|
| ki |
| user output |
|---|
| impossible |
Test 17
Verdict: ACCEPTED
| input |
|---|
| gauouzffisuxjtuufqdappivxv 205... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 18
Verdict: WRONG ANSWER
| input |
|---|
| ovqzprxiluehkndsmtyafbwgjc 2 oo |
| correct output |
|---|
| tt |
| user output |
|---|
| 17 1 3 0 12 9 6 8 11 18 16 7 2... |
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: WRONG ANSWER
| input |
|---|
| eawzhgmusltxjypkirbcfndovq 262... |
| correct output |
|---|
| a |
| user output |
|---|
| 3 22 11 14 25 18 1 16 19 4 12 ... |
Test 22
Verdict: WRONG ANSWER
| input |
|---|
| kqdpgnevpuyahrjclfzwsomxti 2 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkk... |
| correct output |
|---|
| llllllllllllllllllllllllllllll... |
| user output |
|---|
| impossible |
Test 23
Verdict: ACCEPTED
| input |
|---|
| xwfgenquyctxdvmptcrdhvcxwq 778... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 24
Verdict: WRONG ANSWER
| input |
|---|
| sucejvkmrhtobzxglapdnifqwy 1 qddqqqqqdqqqqddddqqdqqqdqdqddq... |
| correct output |
|---|
| xttxxxxxtxxxxttttxxtxxxtxtxttx... |
| user output |
|---|
| 17 12 2 19 3 22 15 9 21 4 6 16... |
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: WRONG ANSWER
| input |
|---|
| zqynskaxvcljewmfditourgpbh 756... |
| correct output |
|---|
| oooooooooooooooooooooooooooooo... |
| user output |
|---|
| 23 13 16 6 14 9 7 5 8 1 2 24 1... |
Test 28
Verdict: WRONG ANSWER
| input |
|---|
| truzcldhkeqspoabgyvmjwnfik 1 zz |
| correct output |
|---|
| dd |
| user output |
|---|
| impossible |
Test 29
Verdict: ACCEPTED
| input |
|---|
| upfasuzkjuwhrnajgmitgysvil 467... |
| correct output |
|---|
| impossible |
| user output |
|---|
| impossible |
Test 30
Verdict: WRONG ANSWER
| input |
|---|
| bemlodzqjgixuksatvyfcpnhrw 1 zdaaskooqkzzifuzspzayokihzxqhf... |
| correct output |
|---|
| gfpponeehnggktmgovgpsenkxglhxt... |
| user output |
|---|
| 15 0 20 5 1 19 9 23 10 8 13 3 ... |
