結果

問題 No.850 企業コンテスト2位
ユーザー omochana2omochana2
提出日時 2019-03-27 17:41:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,316 bytes
コンパイル時間 1,243 ms
コンパイル使用メモリ 151,160 KB
実行使用メモリ 26,924 KB
平均クエリ数 388.64
最終ジャッジ日時 2023-09-23 16:53:23
合計ジャッジ時間 8,558 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

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;

	vector<int> cand;
	int front = rand() % N;
	vector<int> vec;
	rep(i, 0, N) {
		if(front == i) continue;
		vec.pb(i);
	}
	while(!vec.empty()) {
		int n = sz(vec);
		int b = vec[rand() % n];
		cout << "? " << front + 1 << " " << b + 1 << "\n";
		int c; cin >> c; c--;
		if(c == front) cand.pb(b);
		else {
			cand.clear(); cand.pb(front);
			front = b;
		}
		vector<int> nvec;
		rep(i, 0, sz(vec)) {
			if(vec[i] == b) continue;
			nvec.pb(vec[i]);
		}
		vec = nvec;
		debug(vec, front, cand);
	}
	int s = cand[0];
	rep(i, 1, sz(cand)) {
		int a = cand[i];
		cout << "? " << s + 1 << " " << a + 1 << "\n";
		int c; cin >> c; c--;
		if(c == a) s = a;
	}
	cout << "! " << s + 1 << "\n";
}

int main() {
	solve();
}

0