結果

問題 No.1020 Reverse
ユーザー catuppercatupper
提出日時 2020-04-10 21:53:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 933 ms
コンパイル使用メモリ 80,480 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 00:24:50
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 6 ms
4,352 KB
testcase_08 AC 6 ms
4,352 KB
testcase_09 AC 6 ms
4,348 KB
testcase_10 AC 8 ms
4,352 KB
testcase_11 AC 8 ms
4,352 KB
testcase_12 AC 9 ms
4,352 KB
testcase_13 AC 7 ms
4,352 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 7 ms
4,352 KB
testcase_16 AC 8 ms
4,348 KB
testcase_17 AC 7 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;



int main(){
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    for(int i = k-1;i < n;i++)cout << s[i];
    if((n-k)%2 ==0)
        for(int i = k-2;i >= 0;i--)cout << s[i];
    else
        for(int i = 0;i < k-1;i++)cout << s[i];
    cout << endl;
    return 0;
}
0