結果

問題 No.1020 Reverse
ユーザー HomuhomuHomuhomu
提出日時 2020-04-19 23:46:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 503 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 69,620 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-16 00:23:42
合計ジャッジ時間 8,101 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1,279 ms
5,376 KB
testcase_08 TLE -
testcase_09 AC 136 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;
		}
	}
	for (auto itr = v.begin(); itr != v.end(); ++itr)
		cout << S[*itr];
	cout << endl;
	return 0;
}
0