結果

問題 No.1020 Reverse
ユーザー Homuhomu
提出日時 2020-04-19 23:46:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 503 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 69,932 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-10-06 08:12:40
合計ジャッジ時間 8,129 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 TLE * 2 -- * 7
権限があれば一括ダウンロードができます

ソースコード

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