結果

問題 No.1149 色塗りゲーム
ユーザー shojin_proshojin_pro
提出日時 2020-08-07 22:01:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 3,539 bytes
コンパイル時間 3,079 ms
コンパイル使用メモリ 81,284 KB
実行使用メモリ 70,576 KB
平均クエリ数 19.82
最終ジャッジ日時 2023-09-24 04:29:12
合計ジャッジ時間 13,358 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
67,440 KB
testcase_01 AC 106 ms
66,956 KB
testcase_02 AC 134 ms
69,972 KB
testcase_03 AC 127 ms
67,972 KB
testcase_04 AC 136 ms
69,392 KB
testcase_05 AC 136 ms
70,332 KB
testcase_06 AC 137 ms
69,688 KB
testcase_07 AC 133 ms
69,636 KB
testcase_08 AC 135 ms
70,576 KB
testcase_09 AC 133 ms
69,512 KB
testcase_10 AC 139 ms
69,952 KB
testcase_11 AC 138 ms
69,980 KB
testcase_12 AC 135 ms
69,680 KB
testcase_13 AC 137 ms
69,712 KB
testcase_14 AC 139 ms
69,648 KB
testcase_15 AC 139 ms
70,296 KB
testcase_16 AC 138 ms
68,476 KB
testcase_17 AC 138 ms
70,100 KB
testcase_18 AC 137 ms
70,116 KB
testcase_19 AC 140 ms
69,800 KB
testcase_20 AC 136 ms
69,888 KB
testcase_21 AC 135 ms
70,020 KB
testcase_22 AC 136 ms
70,112 KB
testcase_23 AC 139 ms
70,396 KB
testcase_24 AC 138 ms
70,100 KB
testcase_25 AC 139 ms
69,540 KB
testcase_26 AC 142 ms
69,440 KB
testcase_27 AC 142 ms
70,124 KB
testcase_28 AC 144 ms
70,368 KB
testcase_29 AC 143 ms
69,816 KB
testcase_30 AC 190 ms
70,044 KB
testcase_31 AC 181 ms
70,196 KB
testcase_32 AC 186 ms
70,136 KB
testcase_33 AC 188 ms
69,860 KB
testcase_34 AC 189 ms
69,740 KB
testcase_35 AC 185 ms
69,676 KB
testcase_36 AC 194 ms
69,888 KB
testcase_37 AC 196 ms
69,576 KB
testcase_38 AC 187 ms
70,528 KB
testcase_39 AC 194 ms
70,376 KB
testcase_40 AC 203 ms
70,136 KB
testcase_41 AC 200 ms
70,080 KB
testcase_42 AC 196 ms
69,696 KB
testcase_43 AC 196 ms
69,872 KB
testcase_44 AC 204 ms
69,768 KB
testcase_45 AC 205 ms
69,908 KB
testcase_46 AC 206 ms
69,624 KB
testcase_47 AC 210 ms
70,180 KB
testcase_48 AC 210 ms
70,368 KB
testcase_49 AC 215 ms
70,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        if(n <= 2){
            pw.println(n + " 1");
            pw.flush();
            int t = sc.nextInt();
            return;
        }else{
            int center = (1+n)/2;
            boolean isEven = n % 2 == 0;
            String next = "";
            if(isEven){
                next += 2 + " " + center;
            }else{
                next += 1 + " " + center;
            }
            while(true){
                pw.println(next);
                pw.flush();
                int t = sc.nextInt();
                if(t != 3){
                    if(t == 2){
                        int lose = sc.nextInt();
                    }
                    return;
                }
                int cnt = sc.nextInt();
                int k = sc.nextInt();
                int nextK = k+cnt-1;
                if(isEven){
                    nextK = (center*2+1) + ((center*2+1)-nextK*2);
                    nextK /= 2;
                }else{
                    nextK = center + (center-nextK);
                }
                next = cnt + " " + nextK;
            }
        }
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}
0