Submission #345945


Source Code Expand

Copy
#!/usr/bin/env python

import sys


def read():
    return input()


def query(a, b):
    print "? %d %d" % (a, b)
    sys.stdout.flush()
    return input()


def getFurtherestPt(N, src):
    maxV = 0
    furtherestPt = -1
    
    for i in range(N):
        if i == src:
            continue

        dist = query(src + 1, i + 1)

        if maxV < dist:
            maxV = dist
            furtherestPt = i

    return furtherestPt
        

def work(N):
    furtherestPt1 = getFurtherestPt(N, 0)
    furtherestPt2 = getFurtherestPt(N, furtherestPt1)

    print "! %d" % query(furtherestPt1 + 1, furtherestPt2 + 1)


if __name__ == "__main__":
    work(read())

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User Hachimori
Language Python (2.7.3)
Score 100
Code Size 704 Byte
Status
Exec Time 69 ms
Memory 3816 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 60 ms 3676 KB
subtask1_0.txt 65 ms 3792 KB
subtask1_1.txt 68 ms 3788 KB
subtask1_10.txt 69 ms 3780 KB
subtask1_11.txt 64 ms 3768 KB
subtask1_12.txt 66 ms 3788 KB
subtask1_13.txt 66 ms 3816 KB
subtask1_14.txt 69 ms 3784 KB
subtask1_15.txt 64 ms 3736 KB
subtask1_16.txt 62 ms 3768 KB
subtask1_17.txt 68 ms 3764 KB
subtask1_18.txt 65 ms 3676 KB
subtask1_19.txt 67 ms 3780 KB
subtask1_2.txt 67 ms 3724 KB
subtask1_20.txt 58 ms 3776 KB
subtask1_3.txt 68 ms 3772 KB
subtask1_4.txt 68 ms 3712 KB
subtask1_5.txt 67 ms 3780 KB
subtask1_6.txt 66 ms 3772 KB
subtask1_7.txt 69 ms 3780 KB
subtask1_8.txt 64 ms 3788 KB
subtask1_9.txt 68 ms 3724 KB
subtask2_0.txt 67 ms 3780 KB
subtask2_1.txt 64 ms 3776 KB
subtask2_10.txt 65 ms 3788 KB
subtask2_11.txt 66 ms 3788 KB
subtask2_12.txt 65 ms 3776 KB
subtask2_13.txt 68 ms 3760 KB
subtask2_14.txt 66 ms 3756 KB
subtask2_15.txt 69 ms 3672 KB
subtask2_16.txt 67 ms 3796 KB
subtask2_17.txt 66 ms 3792 KB
subtask2_18.txt 66 ms 3788 KB
subtask2_19.txt 67 ms 3776 KB
subtask2_2.txt 67 ms 3780 KB
subtask2_3.txt 68 ms 3772 KB
subtask2_4.txt 68 ms 3788 KB
subtask2_5.txt 66 ms 3788 KB
subtask2_6.txt 65 ms 3724 KB
subtask2_7.txt 67 ms 3792 KB
subtask2_8.txt 66 ms 3744 KB
subtask2_9.txt 67 ms 3792 KB