結果

問題 No.850 企業コンテスト2位
ユーザー yurujirouyurujirou
提出日時 2021-10-16 15:18:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,367 bytes
コンパイル時間 4,274 ms
コンパイル使用メモリ 265,252 KB
実行使用メモリ 24,660 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-10-17 22:13:03
合計ジャッジ時間 8,114 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,648 KB
testcase_01 AC 25 ms
24,648 KB
testcase_02 AC 24 ms
24,648 KB
testcase_03 AC 24 ms
24,648 KB
testcase_04 AC 23 ms
24,648 KB
testcase_05 AC 23 ms
24,648 KB
testcase_06 AC 25 ms
24,648 KB
testcase_07 AC 28 ms
24,648 KB
testcase_08 AC 29 ms
24,648 KB
testcase_09 AC 30 ms
24,648 KB
testcase_10 AC 34 ms
24,648 KB
testcase_11 AC 34 ms
24,648 KB
testcase_12 AC 33 ms
24,648 KB
testcase_13 AC 33 ms
24,648 KB
testcase_14 AC 34 ms
24,648 KB
testcase_15 AC 32 ms
24,648 KB
testcase_16 AC 33 ms
24,648 KB
testcase_17 AC 34 ms
24,648 KB
testcase_18 AC 33 ms
24,648 KB
testcase_19 AC 33 ms
24,648 KB
testcase_20 AC 33 ms
24,648 KB
testcase_21 AC 34 ms
24,648 KB
testcase_22 AC 34 ms
24,648 KB
testcase_23 AC 34 ms
24,648 KB
testcase_24 AC 33 ms
24,648 KB
testcase_25 AC 34 ms
24,648 KB
testcase_26 AC 34 ms
24,648 KB
testcase_27 AC 24 ms
24,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define RREP(i,n) for(int i = (int)n-1; i >= 0; i--)
#define LREP(i,n) for(LL i = 0; i < (LL)n; i++)

#define Vi vector<int>
#define Vl vector<long long>
#define P pair<int, int>
#define LP pair<long long ,long long>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE 400010
#define MOD 998244353
typedef long long LL;

#define M 512

int N;
int A[2 * M];

int dfs(int index) {
	if (index >= M) {
		return A[index] = index - M + 1;
	}
	int res;
	int a = dfs(index * 2), b = dfs(index * 2 + 1);
	if (a > N || b > N) {
		res = min(a, b);
	}
	else {
		cout << "? " << a << " " << b << endl;
		cin >> res;
	}
	return A[index] = res;
}

int main() {
	cin >> N;
	
	int t = dfs(1);
	queue<int> que;
	int index = 1;
	while (index < M) {
		if (A[index * 2] == t) {
			que.push(A[index * 2 + 1]);
			index = index * 2;
		}
		else {
			que.push(A[index * 2]);
			index = index * 2 + 1;
		}
	}
	int a = que.front(); que.pop();
	while (que.size()) {
		int b = que.front(); que.pop();
		if (a > N || b > N) {
			a = min(a, b);
		}
		else {
			cout << "? " << a << " " << b << endl;
			cin >> a;
		}
	}
	cout << "! " << a << endl;
}
0