結果
| 問題 | No.26 シャッフルゲーム | 
| コンテスト | |
| ユーザー |  toto | 
| 提出日時 | 2025-03-27 09:54:32 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 608 bytes | 
| コンパイル時間 | 362 ms | 
| コンパイル使用メモリ | 27,776 KB | 
| 実行使用メモリ | 7,324 KB | 
| 最終ジャッジ日時 | 2025-03-27 09:54:34 | 
| 合計ジャッジ時間 | 1,184 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d",&loc);
      |         ~~~~~^~~~~~~~~~~
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%d",&change1,&change2);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
int main(){
	// カップ
	int cup[3] = {0,0,0};
	
	// 〇カップの位置
	int loc = 0;
	scanf("%d",&loc);
	
	// 〇カップの位置を配列に記憶
	cup[loc - 1] = 1;
	
	// カップを入れ替える回数
	int count = 0;
	scanf("%d",&count);
	// カップの入れ替え
	int change1,change2;
	for(int i = 0;i < count;i ++){
		scanf("%d%d",&change1,&change2);
		int tmp = cup[change1 - 1];
		cup[change1 - 1] = cup[change2 - 1];
		cup[change2 - 1] = tmp;
	}
	
	// 〇カップの位置を表示
	for(int i = 0;i < 3;i ++){
		if(cup[i] == 1){
			printf("%d",i + 1);	
		}
	}
	
	
}
            
            
            
        