結果

問題 No.1020 Reverse
ユーザー musuchika3musuchika3
提出日時 2020-04-11 12:59:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 2,757 ms
コンパイル使用メモリ 168,368 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 02:23:24
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,b,n) for(ll i=b;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    int n;
    int k; string s;
    cin>>n>>k>>s;
    string buff;
    rep(i,0,n-k+1){
        buff+=s[i+k-1];
    }
    string add=s.substr(0,k-1);
    if((n-k-1)%2){
        reverse(add.begin(),add.end());
    }
    buff+=add;
    cout<<buff<<endl;
    return 0;
}


0