結果

問題 No.2357 Guess the Function
ユーザー tsugutsugutsugutsugu
提出日時 2023-06-23 21:46:16
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 1,373 bytes
コンパイル時間 3,041 ms
コンパイル使用メモリ 251,660 KB
実行使用メモリ 24,276 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-13 16:46:20
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,976 KB
testcase_01 AC 26 ms
23,976 KB
testcase_02 AC 26 ms
24,276 KB
testcase_03 AC 26 ms
23,772 KB
testcase_04 AC 26 ms
23,976 KB
testcase_05 AC 27 ms
23,592 KB
testcase_06 AC 27 ms
23,508 KB
testcase_07 AC 26 ms
23,796 KB
testcase_08 AC 29 ms
23,652 KB
testcase_09 AC 27 ms
23,760 KB
testcase_10 AC 27 ms
23,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 1
#endif

struct xorshift {
    using u32 = uint32_t;
    u32 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    xorshift(u32 seed = 0) { z ^= seed; }
    u32 operator()() {
        u32 t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
} rnd;
 
int randint(int l, int r) {
    return l + rnd() % (r - l + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto Ask = [&] (int x) {
        cout << "? " << x << endl;
        int ret;
        cin >> ret;
        return ret;
    };
    int y1 = Ask(100);
    vector<pair<int, int>> can;
    for (int a = 0; a < 100; a++) {
        for (int b = a + 1; b <= 100; b++) {
            if ((a + 100) % b == y1) {
                can.push_back(make_pair(a, b));
            }
        }
    }
    for (int i = 1; i <= 100; i++) {
        set<int> z;
        for (auto [u, v] : can) {
            z.insert((u + i) % v);
        }
        if (can.size() == z.size()) {
            int y2 = Ask(i);
            for (auto [u, v] : can) {
                if (y2 == (u + i) % v) {
                    cout << "! " << u << ' ' << v << endl;
                    return 0;
                }
            }
        }
    }
}
0