結果

問題 No.2357 Guess the Function
ユーザー milanis48663220milanis48663220
提出日時 2023-06-23 23:59:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 2,638 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 127,396 KB
実行使用メモリ 24,372 KB
平均クエリ数 2.91
最終ジャッジ日時 2023-09-13 19:09:06
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,036 KB
testcase_01 AC 25 ms
23,868 KB
testcase_02 AC 25 ms
23,436 KB
testcase_03 AC 25 ms
23,868 KB
testcase_04 AC 26 ms
23,664 KB
testcase_05 AC 25 ms
23,700 KB
testcase_06 AC 26 ms
24,372 KB
testcase_07 AC 26 ms
23,436 KB
testcase_08 AC 25 ms
23,880 KB
testcase_09 AC 26 ms
24,348 KB
testcase_10 AC 26 ms
24,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using P = pair<int, int>;

void test(){
    for(int x = 1; x <= 100; x++){
        set<int> st;
        for(int a = 0; a <= 99; a++){
            int b = a+1;
            int r0 = (a+x)%b;
            st.insert(r0);
        }
        debug_value(st.size())
        if(st.size() == 100){
            cout << x << ' ' << endl;
            return;
        }
    }
    debug_value("DONE")
}

void test0(){
    int mx = 0;
    for(int x = 1; x <= 100; x++){
        for(int y = x+1; y <= 100; y++){
            set<P> st;
            for(int a = 0; a <= 99; a++){
                for(int b = a+1; b <= 100; b++){
                    int r0 = (a+x)%b;
                    int r1 = (a+y)%b;
                    st.insert({r0, r1});
                }
            }
            chmax<int>(mx, st.size());
            // debug(st.size())
            if(st.size() == 5050){
                cout << x << ' ' << y << endl;
                return;
            }
        }
    }
    debug_value(mx)
    debug_value("DONE")
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    auto f = [&](int x){
        cout << "? " << x << endl;
        int ans; cin >> ans;
        return ans;
    };
    int a0 = f(100);
    if(a0 == 99){
        cout << "! " << 99 << ' ' << 100 << endl;
        return 0;
    }
    int B = f(100-a0-1)+1;
    int A = (a0-100)%B;
    A += B;
    A %= B;
    cout << "! " << A << ' ' << B << endl;
}
0