結果

問題 No.850 企業コンテスト2位
ユーザー omochana2omochana2
提出日時 2019-03-27 14:41:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 2,400 bytes
コンパイル時間 2,421 ms
コンパイル使用メモリ 149,640 KB
実行使用メモリ 26,996 KB
平均クエリ数 335.00
最終ジャッジ日時 2023-09-23 16:51:51
合計ジャッジ時間 4,436 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
26,236 KB
testcase_01 AC 39 ms
26,068 KB
testcase_02 AC 38 ms
26,280 KB
testcase_03 AC 38 ms
26,692 KB
testcase_04 AC 39 ms
26,536 KB
testcase_05 AC 38 ms
26,284 KB
testcase_06 AC 39 ms
26,192 KB
testcase_07 AC 39 ms
26,344 KB
testcase_08 AC 36 ms
26,468 KB
testcase_09 AC 38 ms
26,724 KB
testcase_10 AC 40 ms
26,628 KB
testcase_11 AC 39 ms
26,712 KB
testcase_12 AC 40 ms
26,356 KB
testcase_13 AC 39 ms
26,020 KB
testcase_14 AC 39 ms
26,220 KB
testcase_15 AC 39 ms
26,016 KB
testcase_16 AC 39 ms
26,076 KB
testcase_17 AC 40 ms
26,996 KB
testcase_18 AC 40 ms
26,636 KB
testcase_19 AC 40 ms
26,768 KB
testcase_20 AC 39 ms
26,136 KB
testcase_21 AC 40 ms
26,416 KB
testcase_22 AC 40 ms
26,068 KB
testcase_23 AC 40 ms
26,100 KB
testcase_24 AC 41 ms
26,752 KB
testcase_25 AC 40 ms
26,376 KB
testcase_26 AC 41 ms
26,492 KB
testcase_27 AC 40 ms
26,188 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);
	int cnt = 334;
	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 << endl;
				cnt--;
				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 << endl;
			cnt--;
			int c;
			cin >> c; c--;
			if(b == c) ans = b;
		}
	}
	while(cnt--) {
		cout << "? " << 1 << " " << 2 << endl;
	}
	cout << "! " << ans + 1 << endl;
}

int main() {
	solve();
}

0