結果
問題 | No.1020 Reverse |
ユーザー |
![]() |
提出日時 | 2020-04-11 17:50:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 67,684 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-19 05:37:40 |
合計ジャッジ時間 | 1,424 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
#include <iostream> #include <string> #include <algorithm> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, k; std::cin >> n >> k; std::string s; std::cin >> s; std::string ans1 = s.substr(k - 1, n - k + 1); std::string ss = s.substr(0, k - 1); std::string t = ss; std::reverse(t.begin(), t.end()); std::string ans2 = (n - k) % 2 == 0 ? t : ss; std::cout << ans1 << ans2 << '\n'; return 0; }