Submission #345376


Source Code Expand

Copy
import static java.util.Arrays.*;

import java.util.Scanner;

public class Main {
	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}
	public static void main(String[] args) {
		new Main().run();
	}

	Scanner sc = new Scanner(System.in);
	void run() {
		int n = sc.nextInt();

		int ans = 0;

		int maxD = 0;
		int maxDid = 0;
		for (int i = 2; i <= n; i++) {
			System.out.printf("? %d %d\n", 1, i);
			System.out.flush();
			int d = sc.nextInt();
			if (maxD < d) {
				maxD = d;
				maxDid = i;
			}
		}
		ans = maxD;
		for (int i = 2; i <= n; i++) if (i != maxDid) {
			System.out.printf("? %d %d\n", maxDid, i);
			System.out.flush();
			int d = sc.nextInt();
			if (ans < d) {
				ans= d;
			}
		}
		System.out.println("! " + ans);

	}

}

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User hs484
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 811 Byte
Status
Exec Time 652 ms
Memory 24668 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_0.txt
Subtask1 20 / 20 subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_20.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask0_0.txt
All 80 / 80 subtask0_0.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_20.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask2_0.txt, subtask2_1.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt 572 ms 23660 KB
subtask1_0.txt 587 ms 24564 KB
subtask1_1.txt 588 ms 24536 KB
subtask1_10.txt 597 ms 24504 KB
subtask1_11.txt 576 ms 24432 KB
subtask1_12.txt 585 ms 24564 KB
subtask1_13.txt 577 ms 24540 KB
subtask1_14.txt 582 ms 24552 KB
subtask1_15.txt 584 ms 24536 KB
subtask1_16.txt 582 ms 24576 KB
subtask1_17.txt 580 ms 24564 KB
subtask1_18.txt 590 ms 24492 KB
subtask1_19.txt 586 ms 24588 KB
subtask1_2.txt 586 ms 24488 KB
subtask1_20.txt 556 ms 23736 KB
subtask1_3.txt 598 ms 24528 KB
subtask1_4.txt 587 ms 24524 KB
subtask1_5.txt 589 ms 24560 KB
subtask1_6.txt 587 ms 24652 KB
subtask1_7.txt 627 ms 24544 KB
subtask1_8.txt 652 ms 24668 KB
subtask1_9.txt 596 ms 24624 KB
subtask2_0.txt 590 ms 24524 KB
subtask2_1.txt 575 ms 24596 KB
subtask2_10.txt 566 ms 24496 KB
subtask2_11.txt 565 ms 24460 KB
subtask2_12.txt 572 ms 24532 KB
subtask2_13.txt 575 ms 24576 KB
subtask2_14.txt 570 ms 24580 KB
subtask2_15.txt 571 ms 24492 KB
subtask2_16.txt 584 ms 24544 KB
subtask2_17.txt 584 ms 24492 KB
subtask2_18.txt 576 ms 24532 KB
subtask2_19.txt 601 ms 24480 KB
subtask2_2.txt 600 ms 24668 KB
subtask2_3.txt 600 ms 24456 KB
subtask2_4.txt 591 ms 24544 KB
subtask2_5.txt 576 ms 24600 KB
subtask2_6.txt 582 ms 24544 KB
subtask2_7.txt 589 ms 24444 KB
subtask2_8.txt 581 ms 24560 KB
subtask2_9.txt 575 ms 24532 KB