Created
February 28, 2015 14:25
-
-
Save ik11235/d53c4d5c195c745ff174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
int n; | |
cin>>n; | |
long long int ans=0; | |
int num; | |
for(int i=2;i<=n;i++) | |
{ | |
cout<<"? "<<1<<" "<<i<<endl; | |
long long int tmp; | |
cin>>tmp; | |
if(tmp>ans) | |
{ | |
ans=tmp; | |
num=i; | |
} | |
} | |
for(int i=1;i<=n;i++) | |
{ | |
if(i==num) | |
continue; | |
cout<<"? "<<num<<" "<<i<<endl; | |
long long int tmp; | |
cin>>tmp; | |
ans=max(ans,tmp); | |
} | |
cout<<"! "<<ans<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment