32 lines
708 B
C++
32 lines
708 B
C++
#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;
|
|
}
|