結果

問題 No.2577 Simple Permutation Guess
ユーザー tentententen
提出日時 2023-12-11 11:53:19
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,720 bytes
コンパイル時間 2,754 ms
コンパイル使用メモリ 85,616 KB
実行使用メモリ 74,856 KB
平均クエリ数 251.95
最終ジャッジ日時 2024-09-27 04:27:02
合計ジャッジ時間 33,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
67,396 KB
testcase_01 AC 468 ms
73,960 KB
testcase_02 AC 255 ms
72,660 KB
testcase_03 AC 99 ms
67,460 KB
testcase_04 AC 323 ms
73,900 KB
testcase_05 AC 355 ms
74,184 KB
testcase_06 AC 525 ms
73,892 KB
testcase_07 AC 526 ms
74,136 KB
testcase_08 AC 530 ms
73,848 KB
testcase_09 AC 551 ms
74,364 KB
testcase_10 AC 532 ms
73,744 KB
testcase_11 AC 101 ms
67,652 KB
testcase_12 AC 93 ms
67,500 KB
testcase_13 AC 113 ms
68,160 KB
testcase_14 AC 105 ms
67,684 KB
testcase_15 AC 96 ms
68,020 KB
testcase_16 AC 90 ms
67,800 KB
testcase_17 AC 90 ms
67,860 KB
testcase_18 AC 88 ms
67,256 KB
testcase_19 AC 90 ms
67,840 KB
testcase_20 AC 90 ms
67,832 KB
testcase_21 AC 88 ms
67,224 KB
testcase_22 AC 90 ms
67,860 KB
testcase_23 AC 93 ms
67,796 KB
testcase_24 RE -
testcase_25 AC 91 ms
67,804 KB
testcase_26 AC 92 ms
67,528 KB
testcase_27 AC 89 ms
66,980 KB
testcase_28 AC 90 ms
67,428 KB
testcase_29 AC 89 ms
67,820 KB
testcase_30 AC 92 ms
67,324 KB
testcase_31 AC 92 ms
67,080 KB
testcase_32 AC 91 ms
68,220 KB
testcase_33 AC 90 ms
67,200 KB
testcase_34 AC 91 ms
67,408 KB
testcase_35 AC 91 ms
67,584 KB
testcase_36 AC 93 ms
67,660 KB
testcase_37 AC 87 ms
67,516 KB
testcase_38 AC 91 ms
67,692 KB
testcase_39 AC 91 ms
67,580 KB
testcase_40 AC 92 ms
67,468 KB
testcase_41 AC 91 ms
67,996 KB
testcase_42 AC 90 ms
67,408 KB
testcase_43 AC 95 ms
67,776 KB
testcase_44 AC 94 ms
67,804 KB
testcase_45 AC 91 ms
67,848 KB
testcase_46 AC 92 ms
67,408 KB
testcase_47 AC 93 ms
67,524 KB
testcase_48 AC 94 ms
67,272 KB
testcase_49 AC 91 ms
67,608 KB
testcase_50 AC 92 ms
67,540 KB
testcase_51 AC 92 ms
67,716 KB
testcase_52 AC 89 ms
67,948 KB
testcase_53 AC 91 ms
67,668 KB
testcase_54 AC 92 ms
67,252 KB
testcase_55 AC 93 ms
67,744 KB
testcase_56 AC 90 ms
67,648 KB
testcase_57 AC 88 ms
67,360 KB
testcase_58 AC 90 ms
67,596 KB
testcase_59 AC 91 ms
67,348 KB
testcase_60 AC 92 ms
67,636 KB
testcase_61 AC 90 ms
67,908 KB
testcase_62 AC 90 ms
67,968 KB
testcase_63 AC 91 ms
67,608 KB
testcase_64 AC 92 ms
68,096 KB
testcase_65 AC 90 ms
67,532 KB
testcase_66 AC 89 ms
67,604 KB
testcase_67 AC 92 ms
67,464 KB
testcase_68 AC 91 ms
67,272 KB
testcase_69 AC 90 ms
67,680 KB
testcase_70 AC 90 ms
67,540 KB
testcase_71 AC 91 ms
67,328 KB
testcase_72 AC 89 ms
67,524 KB
testcase_73 AC 92 ms
67,468 KB
testcase_74 AC 107 ms
67,868 KB
testcase_75 AC 107 ms
68,020 KB
testcase_76 AC 107 ms
68,304 KB
testcase_77 AC 109 ms
67,956 KB
testcase_78 AC 109 ms
68,032 KB
testcase_79 AC 108 ms
67,772 KB
testcase_80 AC 110 ms
67,836 KB
testcase_81 AC 110 ms
67,708 KB
testcase_82 AC 110 ms
67,468 KB
testcase_83 AC 110 ms
67,744 KB
testcase_84 AC 113 ms
68,076 KB
testcase_85 AC 116 ms
67,964 KB
testcase_86 AC 111 ms
67,960 KB
testcase_87 AC 112 ms
67,840 KB
testcase_88 AC 110 ms
67,656 KB
testcase_89 AC 111 ms
67,952 KB
testcase_90 AC 113 ms
68,004 KB
testcase_91 AC 111 ms
67,440 KB
testcase_92 AC 472 ms
74,208 KB
testcase_93 AC 456 ms
74,264 KB
testcase_94 AC 442 ms
74,856 KB
testcase_95 AC 514 ms
73,936 KB
testcase_96 AC 514 ms
74,276 KB
testcase_97 AC 508 ms
73,528 KB
testcase_98 AC 527 ms
74,724 KB
testcase_99 AC 513 ms
73,740 KB
testcase_100 AC 466 ms
73,816 KB
testcase_101 AC 543 ms
74,384 KB
evil_1_rnd_1.txt AC 769 ms
77,152 KB
evil_1_rnd_2.txt AC 755 ms
76,664 KB
evil_2_big_1.txt AC 849 ms
77,124 KB
evil_2_big_2.txt AC 848 ms
84,180 KB
evil_2_big_3.txt AC 852 ms
77,536 KB
evil_3_sorted_1.txt AC 562 ms
75,244 KB
evil_4_sorted_rev_1.txt AC 534 ms
74,652 KB
evil_4_sorted_rev_2.txt AC 658 ms
74,672 KB
evil_400_sorted.txt AC 810 ms
80,928 KB
evil_400_sorted_rev.txt AC 981 ms
85,288 KB
権限があれば一括ダウンロードができます

ソースコード

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 n = sc.nextInt();
        ArrayList<Integer> remain = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            remain.add(i);
        }
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int left = 0;
            int right = remain.size();
            while (right - left > 1) {
                int m = (left + right) / 2;
                ans[i] = remain.get(m);
                int idx = 0;
                for (int j = i + 1; j < n; j++) {
                    if (idx == m) {
                        idx++;
                    }
                    ans[j] = remain.get(idx);
                    idx++;
                }
                System.out.println("? " + String.join(" ", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new)));
                System.out.flush();
                int ret = sc.nextInt();
                if (ret == 0) {
                    right = m;
                }  else if (ret == 1) {
                    left = m;
                } else {
                    return;
                }
            }
            ans[i] = remain.get(left);
            remain.remove(left);
        }
        System.out.println("! " + String.join(" ", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new)));
    }
}
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