Submission #346679


Source Code Expand

int main(){
	int n;
	cin>>n;
	int max=0;
	int maxpoint=0;
	for(int j=2;j<=n;j++){
		int dist;
		cout<<"? "<<1<<" "<<j<<endl;
		cin>>dist;
		if(max<dist){
			max=dist;
			maxpoint=j;
		}
	}
	int maxpoint2=1;
	for(int i=2;i<n;i++){
		if(i==maxpoint)continue;
		int dist;
		cout<<"? "<<maxpoint<<" "<<i<<endl;
		cin>>dist;
		if(max<dist){
			max=dist;
			maxpoint=i;
		}
	}
	cout<<"! "<<max<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User kasimatatomoya
Language C++11 (GCC 4.8.1)
Score 0
Code Size 434 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:3:2: error: ‘cin’ was not declared in this scope
  cin>>n;
  ^
./Main.cpp:8:3: error: ‘cout’ was not declared in this scope
   cout<<"? "<<1<<" "<<j<<endl;
   ^
./Main.cpp:8:26: error: ‘endl’ was not declared in this scope
   cout<<"? "<<1<<" "<<j<<endl;
                          ^
./Main.cpp:19:3: error: ‘cout’ was not declared in this scope
   cout<<"? "<<maxpoint<<" "<<i<<endl;
   ^
./Main.cpp:19:33: error: ‘endl’ was not declared in this scope
   cout<<"? "<<maxpoint<<" "<<i<<endl;
                                 ^
./Main.cpp:26:2: error: ‘cout’ was not declared in this scope
  cout<<"! "<<max<<endl;
  ^
./Main.cpp:26:19: error: ‘endl’ was not declared in this scope
  cout<<"! "<<max<<endl;
                   ^