結果
| 問題 | No.1020 Reverse |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 22:49:00 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 5 ms / 2,000 ms |
| + 721µs | |
| コード長 | 783 bytes |
| 記録 | |
| コンパイル時間 | 992 ms |
| コンパイル使用メモリ | 187,664 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-28 07:53:00 |
| 合計ジャッジ時間 | 2,714 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}