結果
| 問題 |
No.1020 Reverse
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 22:49:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 783 bytes |
| コンパイル時間 | 1,678 ms |
| コンパイル使用メモリ | 172,596 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 23:05:46 |
| 合計ジャッジ時間 | 2,588 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
signed main(){
int n, k;
cin >> n >> k;
string s;
cin >> s;
deque<int> que;
bool f = false;
for(int i = 0;i < k;i++){
que.push_back(s[i]);
}
string ans = "";
for(int i = k;i < n;i++){
if(!f){
ans.push_back(que.back());
que.pop_back();
que.push_front(s[i]);
}else{
ans.push_back(que.front());
que.pop_front();
que.push_back(s[i]);
}
f = !f;
}
if(!f) reverse(que.begin(), que.end());
while(!que.empty()){
ans.push_back(que.front());
que.pop_front();
}
cout << ans << endl;
return 0;
}