結果

問題 No.2521 Don't be Same
ユーザー ks2m
提出日時 2023-10-27 23:42:23
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 1,433 bytes
コンパイル時間 2,539 ms
コンパイル使用メモリ 79,004 KB
実行使用メモリ 67,184 KB
平均クエリ数 9.71
最終ジャッジ日時 2024-09-25 15:32:18
合計ジャッジ時間 11,080 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other AC * 14 RE * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		int a = Math.min(x, y);
		int b = Math.max(x, y);
		boolean f = true;
		if (a + 1 == b && a % 2 == 1) {
			f = false;
		}
		if (f) {
			System.out.println("First");
			if (x == y) {
				System.out.println("B");
				x = 0;
				y = 0;
			} else if (x > y) {
				int r = 0;
				if (y % 2 == 0) {
					r = x - y + 1;
				} else {
					r = x - y - 1;
				}
				System.out.println("A 1 " + r);
				x -= r;
			} else {
				int r = 0;
				if (x % 2 == 0) {
					r = y - x + 1;
				} else {
					r = y - x - 1;
				}
				System.out.println("A 2 " + r);
				y -= r;
			}
		} else {
			System.out.println("Second");
		}

		while (true) {
			String s = sc.next();
			if (s.equals("C") || s.equals("D")) {
				break;
			}
			int i = sc.nextInt();
			int n = sc.nextInt();
			if (i == 1) {
				x -= n;
			} else {
				y -= n;
			}

			if (x == y) {
				System.out.println("B");
				x = 0;
				y = 0;
			} else if (x > y) {
				int r = 0;
				if (y % 2 == 0) {
					r = x - y + 1;
				} else {
					r = x - y - 1;
				}
				System.out.println("A 1 " + r);
				x -= r;
			} else {
				int r = 0;
				if (x % 2 == 0) {
					r = y - x + 1;
				} else {
					r = y - x - 1;
				}
				System.out.println("A 2 " + r);
				y -= r;
			}
		}
		sc.close();
	}
}
0