結果

問題 No.123 カードシャッフル
ユーザー sasa
提出日時 2025-03-06 11:07:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 424 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 27,776 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2025-03-06 11:07:09
合計ジャッジ時間 1,405 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d",&num);
      |         ~~~~~^~~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&count);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d",&location);
      |                 ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
		for(int i = 0;i < num;i++){
		}
	}
	printf("%d",p[0]);
}
0