結果

問題 No.2252 Find Zero
ユーザー ThistleThistle
提出日時 2023-03-24 21:29:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 3,000 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 120,316 KB
実行使用メモリ 24,648 KB
平均クエリ数 195.78
最終ジャッジ日時 2023-10-18 20:46:29
合計ジャッジ時間 3,447 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
24,648 KB
testcase_01 AC 76 ms
24,648 KB
testcase_02 AC 54 ms
24,648 KB
testcase_03 AC 65 ms
24,648 KB
testcase_04 AC 56 ms
24,648 KB
testcase_05 AC 55 ms
24,648 KB
testcase_06 AC 55 ms
24,648 KB
testcase_07 AC 54 ms
24,648 KB
testcase_08 AC 64 ms
24,648 KB
testcase_09 AC 66 ms
24,648 KB
testcase_10 AC 53 ms
24,648 KB
testcase_11 AC 53 ms
24,648 KB
testcase_12 AC 52 ms
24,648 KB
testcase_13 AC 54 ms
24,648 KB
testcase_14 AC 52 ms
24,648 KB
testcase_15 AC 54 ms
24,648 KB
testcase_16 AC 54 ms
24,648 KB
testcase_17 AC 54 ms
24,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target ("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<limits>
#include<complex>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include<tuple>
using namespace std;
using ll = long long;
using ld = long double;
using H = pair<ll, ll>;
using P = pair<ll, H>;
using vi = vector<int>;
using vl = vector<ll>;
#define all(a) (a).begin(),(a).end()
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define Q(i,j,k) mkp((i),mkp((j),(k)))
#define rng(i,s,n) for(int i = (s) ; i < (n) ; i++)
#define rep(i,n) rng(i, 0, (n))
#define mkp make_pair
#define vec vector
#define pb emplace_back
#define siz(a) int((a).size())
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define getidx(b,i) (lower_bound(all((b)),(i))-(b).begin())
#define ssp(i,n) (i==(ll)(n)-1?"\n":" ")
#define ctoi(c) (int)((c)-'0')
#define itoc(c) (char)((c)+'0')
#define cyes printf("Yes\n")
#define cno printf("No\n")
#define cdf(n) for(int __quetimes=(n);__quetimes>0;__quetimes--)
#define gcj printf("Case #%lld: ",__quetimes+1)
#define readv(a,n) (a).resize((n),0);rep(i,(n)) (a)[i]=read()
#define found(a,x) (a.find(x)!=a.end())
constexpr ll mod = (ll)1e9 + 7;
constexpr ll Mod = 998244353;
constexpr ld EPS = 1e-10;
constexpr ll inf = (ll)3 * 1e18;
constexpr int Inf = 1e9;
constexpr int dx[] = { -1,1,0,0 }, dy[] = { 0,0,-1,1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
bool ina(H t, int h, int w) { return 0 <= t.fs && t.fs < h && 0 <= t.sc && t.sc < w; }
bool ina(int t, int l, int r) { return l <= t && t < r; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
template<typename T>
void fin(T x) { cout << x << endl; exit(0); }
//--------------------------------------------------------------

signed main() {
    set<int>se;
    int n; cin >> n;
    rep(i, n) se.insert(i);
    while (se.size() > 1) {
        int s = *se.begin(); se.erase(se.begin());
        int t = *se.begin(); se.erase(se.begin());
        cout << "? " << s << " " << t << endl;
        int res; cin >> res;
        if (res == s || res == t) {
            if (res == s) cout << "! " << t << endl;
            else cout << "! " << s << endl;
        }
    }
    if (siz(se) > 0) cout << "! " << *se.begin() << endl;
}
0