Submission #345472


Source Code Expand

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	int u = 1;
	int d = 0, v = 0;
	for(int z = 0; z < 2; ++z){
		d = -1;
		for(int i = 1; i <= n; ++i)
		if(i != u){
			printf("? %d %d\n", u, i);
			fflush(stdout);
			int a;
			scanf("%d", &a);
			if(a > d){
				d = a;
				v = i;
			}
		}
		u = v;
	}
	printf("! %d\n", d);
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}

Submission Info

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

Compile Error

./Main.cpp: In function ‘void {anonymous}::mainmain()’:
./Main.cpp:81:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:91:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &a);
                   ^

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 1080 KB
subtask1_0.txt AC 35 ms 1132 KB
subtask1_1.txt AC 32 ms 1208 KB
subtask1_10.txt AC 33 ms 1280 KB
subtask1_11.txt AC 34 ms 1208 KB
subtask1_12.txt AC 31 ms 1212 KB
subtask1_13.txt AC 33 ms 1288 KB
subtask1_14.txt AC 34 ms 1204 KB
subtask1_15.txt AC 37 ms 1216 KB
subtask1_16.txt AC 33 ms 1160 KB
subtask1_17.txt AC 33 ms 1208 KB
subtask1_18.txt AC 34 ms 1128 KB
subtask1_19.txt AC 34 ms 1256 KB
subtask1_2.txt AC 34 ms 1256 KB
subtask1_20.txt AC 30 ms 1236 KB
subtask1_3.txt AC 33 ms 1232 KB
subtask1_4.txt AC 34 ms 1276 KB
subtask1_5.txt AC 32 ms 1132 KB
subtask1_6.txt AC 34 ms 1220 KB
subtask1_7.txt AC 35 ms 1120 KB
subtask1_8.txt AC 36 ms 1200 KB
subtask1_9.txt AC 31 ms 1224 KB
subtask2_0.txt AC 34 ms 1200 KB
subtask2_1.txt AC 32 ms 1140 KB
subtask2_10.txt AC 34 ms 1216 KB
subtask2_11.txt AC 34 ms 1284 KB
subtask2_12.txt AC 31 ms 1212 KB
subtask2_13.txt AC 34 ms 1228 KB
subtask2_14.txt AC 34 ms 1236 KB
subtask2_15.txt AC 35 ms 1280 KB
subtask2_16.txt AC 33 ms 1200 KB
subtask2_17.txt AC 34 ms 1220 KB
subtask2_18.txt AC 34 ms 1276 KB
subtask2_19.txt AC 34 ms 1224 KB
subtask2_2.txt AC 33 ms 1204 KB
subtask2_3.txt AC 35 ms 1128 KB
subtask2_4.txt AC 33 ms 1232 KB
subtask2_5.txt AC 33 ms 1224 KB
subtask2_6.txt AC 34 ms 1284 KB
subtask2_7.txt AC 36 ms 1284 KB
subtask2_8.txt AC 38 ms 1232 KB
subtask2_9.txt AC 35 ms 1244 KB