Submission #345792


Source Code Expand

#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = VT< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int query( const int a, const int b )
{
	cout << "? " << a + 1 << ' ' << b + 1 << endl;
	int res;
	cin >> res;
	return res;
}

int farthest( const int N, const int v, int &dist )
{
	int res = v;
	REP( i, N )
	{
		const int d = query( v, i );
		if ( dist < d )
		{
			res = i;
			dist = d;
		}
	}
	return res;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	int N;
	cin >> N;

	int d = 0;
	const int v = farthest( N, 0, d );
	farthest( N, v, d );

	cout << "! " << d << endl;

	return 0;
}

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User torus711
Language C++11 (GCC 4.8.1)
Score 100
Code Size 2755 Byte
Status AC
Exec Time 39 ms
Memory 1288 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 20 / 20 80 / 80
Status
AC × 1
AC × 22
AC × 42
Set Name Test Cases
Sample subtask0_0.txt
Subtask1 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 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 AC 30 ms 1128 KB
subtask1_0.txt AC 33 ms 1204 KB
subtask1_1.txt AC 33 ms 1132 KB
subtask1_10.txt AC 35 ms 1268 KB
subtask1_11.txt AC 32 ms 1216 KB
subtask1_12.txt AC 33 ms 1228 KB
subtask1_13.txt AC 34 ms 1228 KB
subtask1_14.txt AC 34 ms 1224 KB
subtask1_15.txt AC 34 ms 1220 KB
subtask1_16.txt AC 39 ms 1120 KB
subtask1_17.txt AC 36 ms 1076 KB
subtask1_18.txt AC 33 ms 1204 KB
subtask1_19.txt AC 36 ms 1220 KB
subtask1_2.txt AC 34 ms 1208 KB
subtask1_20.txt AC 31 ms 1132 KB
subtask1_3.txt AC 36 ms 1168 KB
subtask1_4.txt AC 34 ms 1132 KB
subtask1_5.txt AC 34 ms 1128 KB
subtask1_6.txt AC 33 ms 1220 KB
subtask1_7.txt AC 35 ms 1136 KB
subtask1_8.txt AC 31 ms 1228 KB
subtask1_9.txt AC 31 ms 1228 KB
subtask2_0.txt AC 34 ms 1228 KB
subtask2_1.txt AC 33 ms 1228 KB
subtask2_10.txt AC 34 ms 1288 KB
subtask2_11.txt AC 32 ms 1280 KB
subtask2_12.txt AC 33 ms 1216 KB
subtask2_13.txt AC 33 ms 1220 KB
subtask2_14.txt AC 35 ms 1208 KB
subtask2_15.txt AC 31 ms 1248 KB
subtask2_16.txt AC 33 ms 1220 KB
subtask2_17.txt AC 32 ms 1272 KB
subtask2_18.txt AC 35 ms 1220 KB
subtask2_19.txt AC 32 ms 1232 KB
subtask2_2.txt AC 35 ms 1208 KB
subtask2_3.txt AC 34 ms 1228 KB
subtask2_4.txt AC 35 ms 1088 KB
subtask2_5.txt AC 32 ms 1140 KB
subtask2_6.txt AC 31 ms 1132 KB
subtask2_7.txt AC 32 ms 1236 KB
subtask2_8.txt AC 34 ms 1240 KB
subtask2_9.txt AC 34 ms 1132 KB