結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 212 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>

using namespace std;
int main() 
{
	int N,K;
	cin >> N;
	cin >> K;
	string S;
	cin >> S;
	for (int i = 1; i <= N - K + 1; ++i)
	{
		int b = i;
		int e = i + K - 1;
		int m = b - 1;
		int n = e - 1;
		while (m != n || m < n)
		{
			char c = S[m];
			S[m] = S[n];
			S[n] = c;
			++m;
			--n;
		}
	}
	cout << S << endl;
	return 0;
}
0