1
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace std;
|
||||
|
||||
string decrypt_snakey(string encrypted, int col) {
|
||||
string decrypted;
|
||||
for (int i = 0; i < col; i++) {
|
||||
for (int offset = 0;; offset++) {
|
||||
try {
|
||||
decrypted += encrypted.at(i + offset * 2 * col);
|
||||
decrypted += encrypted.at((offset + 1) * 2 * col - i - 1);
|
||||
} catch (out_of_range&) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
string encrypted;
|
||||
int col;
|
||||
cin >> col >> encrypted;
|
||||
cout << decrypt_snakey(encrypted, col) << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user