結果

問題 No.850 企業コンテスト2位
ユーザー omochana2omochana2
提出日時 2019-03-27 14:35:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 2,245 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 148,328 KB
実行使用メモリ 26,828 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 16:51:55
合計ジャッジ時間 3,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
26,116 KB
testcase_01 AC 29 ms
25,976 KB
testcase_02 AC 28 ms
26,168 KB
testcase_03 AC 28 ms
26,092 KB
testcase_04 AC 28 ms
26,560 KB
testcase_05 AC 28 ms
26,232 KB
testcase_06 AC 29 ms
25,996 KB
testcase_07 AC 32 ms
26,316 KB
testcase_08 AC 36 ms
26,632 KB
testcase_09 AC 34 ms
26,384 KB
testcase_10 AC 39 ms
26,020 KB
testcase_11 AC 38 ms
26,016 KB
testcase_12 AC 38 ms
26,828 KB
testcase_13 AC 37 ms
25,980 KB
testcase_14 AC 38 ms
26,480 KB
testcase_15 AC 37 ms
26,328 KB
testcase_16 AC 37 ms
26,388 KB
testcase_17 AC 38 ms
26,016 KB
testcase_18 AC 38 ms
26,132 KB
testcase_19 AC 37 ms
26,720 KB
testcase_20 AC 39 ms
26,732 KB
testcase_21 AC 37 ms
26,480 KB
testcase_22 AC 38 ms
26,064 KB
testcase_23 AC 38 ms
26,376 KB
testcase_24 AC 38 ms
26,580 KB
testcase_25 AC 39 ms
26,616 KB
testcase_26 AC 37 ms
26,204 KB
testcase_27 AC 28 ms
26,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<int> vec;
vector<int> G[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) vec.pb(i);
	while(sz(vec) >= 2) {
		vector<int> nvec;
		int n = sz(vec);
		for(int i = 0; i < n; i += 2) {
			if(i == n - 1) nvec.pb(vec[i]);
			else {
				int a = vec[i], b = vec[i + 1];
				cout << "? " << a + 1 << " " << b + 1 << "\n";
				int c;
				cin >> c; c--;
				if(b == c) swap(a, b);
				nvec.pb(a);
				G[a].pb(b);
			}
		}
		vec = nvec;
		// debug(vec);
	}
	int root = vec[0];
	int ans = -1;
	// debug(root, G[root]);
	rep(i, 0, sz(G[root])) {
		int b = G[root][i];
		if(ans == -1) ans = b;
		else {
			cout << "? " << ans + 1 << " " << b + 1 << "\n";
			int c;
			cin >> c; c--;
			if(b == c) ans = b;
		}
	}
	cout << "! " << ans + 1 << "\n";
}

int main() {
	solve();
}

0