結果

問題 No.2521 Don't be Same
ユーザー shobonvipshobonvip
提出日時 2023-10-27 23:21:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 2,209 bytes
コンパイル時間 3,759 ms
コンパイル使用メモリ 263,216 KB
実行使用メモリ 24,636 KB
平均クエリ数 10.50
最終ジャッジ日時 2023-10-27 23:21:27
合計ジャッジ時間 7,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
24,624 KB
testcase_01 AC 55 ms
24,636 KB
testcase_02 AC 69 ms
24,636 KB
testcase_03 AC 66 ms
24,636 KB
testcase_04 AC 55 ms
24,636 KB
testcase_05 AC 56 ms
24,636 KB
testcase_06 AC 55 ms
24,636 KB
testcase_07 AC 56 ms
24,636 KB
testcase_08 AC 55 ms
24,636 KB
testcase_09 AC 56 ms
24,636 KB
testcase_10 AC 54 ms
24,636 KB
testcase_11 AC 59 ms
24,636 KB
testcase_12 AC 61 ms
24,636 KB
testcase_13 AC 66 ms
24,636 KB
testcase_14 AC 54 ms
24,636 KB
testcase_15 AC 55 ms
24,636 KB
testcase_16 AC 55 ms
24,636 KB
testcase_17 AC 55 ms
24,636 KB
testcase_18 AC 54 ms
24,636 KB
testcase_19 AC 57 ms
24,636 KB
testcase_20 AC 56 ms
24,636 KB
testcase_21 AC 56 ms
24,636 KB
testcase_22 AC 61 ms
24,636 KB
testcase_23 AC 57 ms
24,636 KB
testcase_24 AC 57 ms
24,636 KB
testcase_25 AC 68 ms
24,636 KB
testcase_26 AC 56 ms
24,636 KB
testcase_27 AC 54 ms
24,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	int x, y; cin >> x >> y;
	int now = 0;
	if (x % 2 == 0 && y % 2 == 1){
		if (x - 1 == y){
			now = 1;
		}
	}
	if (x % 2 == 1 && y % 2 == 0){
		if (y - 1 == x){
			now = 1;
		}
	}

	if (now == 0){
		cout << "First" << endl;
	}else{
		cout << "Second" << endl;
	}

	auto lft = [&](int x, int y){
		if (y % 2 == 0){
			return y - 1;
		}else{
			return y + 1;
		}
	};

	auto rgt = [&](int x, int y){
		return lft(y, x);
	};

	while(true){
		if (now == 0){
			if (x == y){
				cout << "B" << endl;
				x = 0;
				y = 0;
			}else if(x == 0){
				cout << "A 2 " << y << endl;
				y = 0;	
			}else if(y == 0){
				cout << "A 1 " << x << endl;
				x = 0;	
			}else{
				int v = lft(x, y);
				int w = rgt(x, y);
				if (v < x){
					cout << "A 1 " << x - v << endl;
					x -= x - v;
				}else{
					assert(w < y);
					cout << "A 2 " << y - w << endl;
					y -= y - w;
				}
			}
		}else{
			char c; cin >> c;
			assert(c != 'D');
			if (c == 'C'){
				break;
			}
			if (c == 'A'){
				int k; cin >> k;
				int r; cin >> r;
				if (k == 1){
					x -= r;
				}else{
					assert(k == 2);
					y -= r;
				}
			}else{
				x = 0;
				y = 0;
			}
		}

		now ^= 1;
	}

}

0