結果
問題 | No.1020 Reverse |
ユーザー |
![]() |
提出日時 | 2020-04-10 21:25:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 3,242 ms |
コンパイル使用メモリ | 192,680 KB |
最終ジャッジ日時 | 2025-01-09 15:53:59 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair<ll, ll>; using V = vector<int>; using VL = vector<ll>; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll MOD = 1e9 + 7; constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; template <class T> void chmin(T &a, T b) { a = min(a, b); } template <class T> void chmax(T &a, T b) { a = max(a, b); } void ok() { cerr << "ok" << endl; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n, k; cin >> n >> k; string s; cin >> s; string res = s.substr(k - 1, n - k + 1); string t = s.substr(0, k - 1); if ((n - k) % 2 == 0) { reverse(all(t)); } res += t; cout << res << '\n'; }