結果

問題 No.3274 Arithmetic Right Shift
ユーザー 00 Sakuda
提出日時 2025-09-19 21:23:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 60 ms / 1,500 ms
コード長 515 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 91,064 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-19 21:23:50
合計ジャッジ時間 1,565 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
void solve() {
	int K;cin >> K;
	string S;cin >> S;
	deque<int> que;
	for (int i = 0;i < S.size();i++) que.push_back(S[i]-'0');
	int N = S.size();
	if (K > N) {
		for (int i = 0;i < N;i++) cout << S[0];
		cout << endl;
		return;
	}
	while (K--) {
		que.push_front(que.front());
		que.pop_back();
	}
	while (!que.empty()) {
		cout << que.front();
		que.pop_front();
	}
	cout << endl;
}
int main() {
	int t;cin >> t;
	while (t--) solve();
}
0