結果

問題 No.1020 Reverse
ユーザー HomuhomuHomuhomu
提出日時 2020-04-19 23:40:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 516 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 69,744 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-16 00:23:20
合計ジャッジ時間 5,464 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;
int main() 
{
	int N,K;
	cin >> N;
	cin >> K;
	string S;
	cin >> S;
	std::vector<int> v(S.length());
	iota(v.begin(), v.end(), 0);
	for (int i = 1; i <= N - K + 1; ++i)
	{
		int m = i - 1;
		int n = i + K - 2;
		while (m != n || m < n)
		{
			int c = v[m];
			v[m] = v[n];
			v[n] = c;
			++m;
			--n;
		}
	}
	string R;
	for (auto itr = v.begin(); itr != v.end(); ++itr)
		R += S[*itr];
	cout << R << endl;
	return 0;
}
0