結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2019-07-05 23:35:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 885 bytes |
| コンパイル時間 | 671 ms |
| コンパイル使用メモリ | 75,252 KB |
| 実行使用メモリ | 25,348 KB |
| 平均クエリ数 | 200.11 |
| 最終ジャッジ日時 | 2024-07-16 17:37:06 |
| 合計ジャッジ時間 | 3,408 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int f(int i, int j) {
cout << "? " << i << ' ' << j << endl;
int a;
cin >> a;
return a;
}
int main() {
int n;
cin >> n;
int p[1024] = {};
for (int i = 0; i < n; i++) {
p[i + 512] = i + 1;
}
for (int i = 512 - 1; i > 0; i--) {
if (p[i * 2 + 1] == 0) {
p[i] = p[i * 2];
} else {
p[i] = f(p[i * 2], p[i * 2 + 1]);
}
}
vector<int> q;
int r = 0;
for (int i = 1; i < 512;) {
i = i * 2 + (p[i * 2] != p[i]);
int t = p[i ^ 1];
if (r == 0) {
r = t;
} else if (t != 0) {
r = f(r, t);
}
}
cout << "! " << r << endl;
return 0;
}
merom686