Submission #345152


Source Code Expand

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	scanf("%d", &N);
	pii p(0, 0);
	rep(i, N) if(i != 0) {
		printf("? %d %d\n", 1, i+1);
		fflush(stdout);
		int d;
		scanf("%d", &d);
		amax(p, mp(d, i));
	}
	int x = p.second;
	int ans = 0;
	rep(i, N) if(i != x) {
		printf("? %d %d\n", x+1, i+1);
		fflush(stdout);
		int d;
		scanf("%d", &d);
		amax(ans, d);
	}
	printf("! %d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User anta
Language C++ (G++ 4.6.4)
Score 100
Code Size 1601 Byte
Status AC
Exec Time 91 ms
Memory 1276 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:46:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:55:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

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