結果

問題 No.26 シャッフルゲーム
ユーザー FF256grhyFF256grhy
提出日時 2016-09-04 00:10:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 683 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 25,300 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-09 21:29:47
合計ジャッジ時間 806 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>

#define FOR(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define REV(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define INC0(i, n) FOR(i, 0, n)
#define INC1(i, n) FOR(i, 1, (n) + 1)
#define DEC0(i, n) REV(i, 0, n)
#define DEC1(i, n) REV(i, 1, (n) + 1)

typedef long long   signed int LL;
typedef long long unsigned int LU;


template<typename T> void swap(T& x, T& y) {
	T temp = x;
	x = y;
	y = temp;
	
	return;
}

int n, m;
int a[3];

int main() {
	scanf("%d%d", &n, &m); n--;
	a[n] = 1;
	
	INC0(i, m) {
		int p, q;
		scanf("%d%d", &p, &q); p--; q--;
		swap(a[p], a[q]);
	}
	
	int ans = (a[0] ? 0 : (a[1] ? 1 : 2) );
	
	printf("%d\n", ans + 1);
	
	return 0;
}
0