結果
問題 |
No.1020 Reverse
|
ユーザー |
![]() |
提出日時 | 2020-08-22 14:52:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,033 bytes |
コンパイル時間 | 807 ms |
コンパイル使用メモリ | 97,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 09:11:01 |
合計ジャッジ時間 | 2,065 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<queue> #include<deque> #include<cmath> #include<map> #include<unordered_map> #include<set> #include<cstring> #include<iomanip> //cout << fixed << setprecision(15) << x << endl; using namespace std; typedef long long ll; const ll INF = 1e9 + 8; const ll MOD = 1e9 + 7; const ll LLINF = 1e18; #define Pint pair<int, int> #define rng(i, a, b) for(int i = int(a); i < int(b); i++) #define rnr(i, a, b) for(int i = int(a); i >= int(b); i--) #define rep(i, b) rng(i, 0, b) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() /* -- template -- */ int main() { int n, k; cin >> n >> k; string s; cin >> s; string ans = ""; for(int i = k - 1; i < n; ++i) { ans += s[i]; } if((n - k + 1) % 2 == 0) { for(int i = 0; i < k - 1; ++i) { ans += s[i]; } } else { for(int i = k - 2; i >= 0; --i) { ans += s[i]; } } cout << ans << endl; }