結果
問題 |
No.26 シャッフルゲーム
|
ユーザー |
![]() |
提出日時 | 2025-03-03 13:53:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 977 bytes |
コンパイル時間 | 470 ms |
コンパイル使用メモリ | 29,696 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-03 13:53:23 |
合計ジャッジ時間 | 1,638 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&loc); | ~~~~~^~~~~~~~~~~ main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d",&count); | ~~~~~^~~~~~~~~~~~~ main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d",&rep1); | ~~~~~^~~~~~~~~~~~ main.cpp:26:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d",&rep2); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> int main(void){ // カップの個数 int judgment[3] = {0,0,0}; int *p = judgment; // 〇の初期位置 int loc = 0; scanf("%d",&loc); // 〇の位置を配列に格納 for(int i = 0;i < 3;i++){ if(i == (loc - 1)){ p[i] = 1; } } // 入れ替える回数 int count = 0; scanf("%d",&count); int i = 0; while(i != count){ int rep1 = 0; scanf("%d",&rep1); int rep2 = 0; scanf("%d",&rep2); int irep1 = 0; int irep2 = 0; printf("入替:%d %d\n",rep1,rep2); for(int i = 0;i < 3;i++){ if(i == rep1 - 1){ rep1 = p[i]; irep1 = i; }else if(i == rep2 - 1){ rep2 = p[i]; irep2 = i; } } int tmp = 0; tmp = rep1; rep1 = rep2; rep2 = tmp; p[irep1] = rep1; p[irep2] = rep2; printf("入替後:"); for(int i = 0;i < 3;i++){ printf("%d ",p[i]); } printf("\n"); i++; } for(int i = 0;i < 3;i++){ if(p[i] == 1){ printf("%d",i + 1); } } }