結果

問題 No.282 おもりと天秤(2)
ユーザー GrenacheGrenache
提出日時 2015-09-19 01:48:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,541 ms / 5,000 ms
コード長 2,770 bytes
コンパイル時間 5,744 ms
コンパイル使用メモリ 78,992 KB
実行使用メモリ 85,004 KB
平均クエリ数 212.21
最終ジャッジ日時 2023-09-23 21:38:49
合計ジャッジ時間 29,001 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
65,164 KB
testcase_01 AC 93 ms
67,672 KB
testcase_02 AC 86 ms
66,056 KB
testcase_03 AC 84 ms
66,068 KB
testcase_04 AC 83 ms
66,288 KB
testcase_05 AC 92 ms
67,248 KB
testcase_06 AC 96 ms
67,992 KB
testcase_07 AC 83 ms
66,228 KB
testcase_08 AC 97 ms
65,664 KB
testcase_09 AC 71 ms
66,608 KB
testcase_10 AC 657 ms
74,588 KB
testcase_11 AC 2,133 ms
81,592 KB
testcase_12 AC 707 ms
75,004 KB
testcase_13 AC 1,075 ms
75,524 KB
testcase_14 AC 1,846 ms
85,004 KB
testcase_15 AC 2,188 ms
83,168 KB
testcase_16 AC 179 ms
68,556 KB
testcase_17 AC 950 ms
75,808 KB
testcase_18 AC 1,573 ms
82,192 KB
testcase_19 AC 1,665 ms
82,244 KB
testcase_20 AC 2,431 ms
83,372 KB
testcase_21 AC 2,449 ms
82,812 KB
testcase_22 AC 2,541 ms
81,372 KB
testcase_23 AC 72 ms
65,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;


public class Main_yukicoder282 {

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        pr = new Printer(System.out);

        int n = sc.nextInt();

        int[] lr = new int[2 * n];
        for (int i = 0; i < n; i++) {
        	lr[i] = i + 1;
        }

        for (int i = 0; i < n * n; i++) {
        	if (ask(lr, i % 2)) {
        		ask(lr, 0);
        		break;
        	}
        }

    	StringBuilder s = new StringBuilder();
    	s.append("! ");
    	for (int i = 0; i < n; i++) {
    		if (i != 0) {
    			s.append(' ');
    		}
    		s.append(lr[i]);
    	}
    	
    	pr.println(s);
    	pr.flush();

    	pr.close();
        sc.close();
    }
    
    static boolean ask(int[] lr, int flag) {
    	int n = lr.length;
    	StringBuilder s = new StringBuilder();
    	s.append("? ");
    	for (int i = flag; i < n; i++) {
    		if (i != flag) {
    			s.append(' ');
    		}
    		s.append(lr[i]);
    	}
    	if (flag == 1) {
    		s.append(' ');
    		s.append(lr[n - 1]);
    	}
    	
    	pr.println(s);
    	pr.flush();

    	boolean ret = true;
    	for (int i = 0; i < n / 2; i++) {
    		char ans = sc.next().charAt(0);
    		if (i * 2 + 1 + flag < n / 2 && lr[i * 2 + 1 + flag] != 0 && ans == '>') {
    			int tmp = lr[i * 2 + flag];
    			lr[i * 2 + flag] = lr[i * 2 + 1 + flag];
    			lr[i * 2 + 1 + flag] = tmp;
    			
    			ret = false;
    		}
    	}
    	
    	return ret;
    }
    
    static Scanner sc;
    static Printer pr;
    
	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;
		
		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		
		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}
		
		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

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

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0