結果

問題 No.2521 Don't be Same
ユーザー tenten
提出日時 2023-11-01 13:40:35
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 3,153 bytes
コンパイル時間 4,736 ms
コンパイル使用メモリ 91,164 KB
実行使用メモリ 70,188 KB
平均クエリ数 2.18
最終ジャッジ日時 2024-09-25 17:57:04
合計ジャッジ時間 10,047 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 11 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int x = sc.nextInt();
        int y = sc.nextInt();
        if ((x < y && x % 2 == 1) || (x > y && y % 2 == 1)) {
            System.out.println("Second");
            System.out.flush();
            String type = sc.next();
            if (type.equals("A")) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                if (a == 1) {
                    x -= b;
                } else {
                    y -= b;
                }
            } else {
                return;
            }
        } else {
            System.out.println("First");
            System.out.flush();
        }
        while (true) {
            if (x == y) {
                System.out.println("B");
            } else if (x == 0) {
                System.out.println("A 2 " + y);
            } else if (y == 0) {
                System.out.println("A 1 " + x);
            } else if (x < y) {
                if (x % 2 == 0) {
                    System.out.println("A 2 " + (y - x + 1));
                } else {
                    System.out.println("A 2 " + (y - x - 1));
                }
            } else {
                if (y % 2 == 0) {
                    System.out.println("A 1 " + (x - y + 1));
                } else {
                    System.out.println("A 1 " + (x - y - 1));
                }
            }
            System.out.flush();
            String type = sc.next();
            if (type.equals("A")) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                if (a == 1) {
                    x -= b;
                } else {
                    y -= b;
                }
            } else {
                return;
            }
        }
    }
    
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0