結果

問題 No.1020 Reverse
ユーザー Mayimg
提出日時 2020-04-11 23:36:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 192,236 KB
最終ジャッジ日時 2025-01-09 17:29:53
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int c = 0;
  for (int i = k - 1; i < n; i++) {
    cout << s[i];
    c++;
  }
  if (c % 2 == 1) {
    for (int i = k - 2; i >= 0; i--) {
      cout << s[i];
    }
  } else {
    for (int i = 0; i <= k - 2; i++) {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}
0