結果

問題 No.2252 Find Zero
ユーザー lddlinanlddlinan
提出日時 2023-03-24 22:02:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,193 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 84,768 KB
実行使用メモリ 24,516 KB
平均クエリ数 74.33
最終ジャッジ日時 2023-10-18 21:04:21
合計ジャッジ時間 2,932 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};



char mk[1004];
int pp[32];
int main() {
    int n, i, j, v, p, k, a, b;
    scanf("%d", &n);
    p=-1;
    for (i=0; i<n; i++) mk[i]=0;
    i=0; while(1) {
        if (p==-1) {
            while(i<n&&mk[i]) i++;
            a=i++;
            while(i<n&&mk[i]) i++;
            if (i>=n) { p=a; break; }
            b=i++;
        } else {
            while(i<n&&mk[i]) i++;
            if (i>=n) break;
            a=i++;
            b=p;
        }
        mk[a]=1; mk[b]=1;
        printf("? %d %d\n", a, b); fflush(stdout);
        scanf("%d", &k);
        if (k==a) { p=b; break; }
        if (k==b) { p=a; break; }
        if (mk[k]) p=-1;
        else { p=k; mk[k]=1; }
    }
    printf("! %d\n", p);
    fflush(stdout);
    return 0;
}
0