結果
| 問題 |
No.3274 Arithmetic Right Shift
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-09-20 10:59:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 1,500 ms |
| コード長 | 540 bytes |
| コンパイル時間 | 370 ms |
| コンパイル使用メモリ | 41,940 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-20 10:59:23 |
| 合計ジャッジ時間 | 1,186 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d", &tn);
| ~~~~~^~~~~~~~~~~
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%d%s", &k, s);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3274.cc: No.3274 Arithmetic Right Shift - yukicoder
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 64;
/* typedef */
/* global variables */
char s[MAX_N + 4];
/* subroutines */
/* main */
int main() {
int tn;
scanf("%d", &tn);
while (tn--) {
int k;
scanf("%d%s", &k, s);
int n = strlen(s);
k = min(k, n - 1);
for (int i = n - 1; i >= 1; i--) s[i] = s[max(0, i - k)];
puts(s);
}
return 0;
}
tnakao0123