結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-16 15:18:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 1,367 bytes |
| コンパイル時間 | 5,009 ms |
| コンパイル使用メモリ | 252,612 KB |
| 最終ジャッジ日時 | 2025-01-25 01:35:13 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
#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;
}