結果
| 問題 |
No.123 カードシャッフル
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-06 10:53:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 494 bytes |
| コンパイル時間 | 455 ms |
| コンパイル使用メモリ | 28,160 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-06 10:53:17 |
| 合計ジャッジ時間 | 1,389 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 6 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d",&num);
| ~~~~~^~~~~~~~~~~
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d",&count);
| ~~~~~^~~~~~~~~~~~~
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d",&location);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(){
// カードの枚数
int num = 0;
scanf("%d",&num);
// カードの順
int card[num];
int *p = card;
for(int i = 0;i < num;i++){
p[i] = i + 1;
}
// シャッフルの回数
int count = 0;
scanf("%d",&count);
// シャッフルする位置
int location = 0;
for(int i = 0;i < count;i++){
scanf("%d",&location);
int tmp = p[location - 1];
for(int i = location - 2;i > 0;i--){
p[i + 1] = p[i];
}
p[0] = tmp;
}
printf("%d",p[0]);
}
sasa