結果

問題 No.2357 Guess the Function
ユーザー as277575as277575
提出日時 2023-06-23 22:52:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 1,004 bytes
コンパイル時間 1,298 ms
コンパイル使用メモリ 129,484 KB
実行使用メモリ 24,372 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-13 17:59:14
合計ジャッジ時間 2,395 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,372 KB
testcase_01 AC 25 ms
24,240 KB
testcase_02 AC 25 ms
24,084 KB
testcase_03 AC 25 ms
24,132 KB
testcase_04 AC 25 ms
23,556 KB
testcase_05 AC 24 ms
24,360 KB
testcase_06 AC 24 ms
23,292 KB
testcase_07 AC 25 ms
23,760 KB
testcase_08 AC 23 ms
23,676 KB
testcase_09 AC 25 ms
23,448 KB
testcase_10 AC 24 ms
23,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bit>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template <typename T>
void print(const T& v) {
 for (const auto& x : v) cout << x << " ";
 cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cout << "? 50" << endl;
  int u;
  cin >> u;
  
  vector<pair<int, int>> p;
  for (int a = 0; a < 100; ++a)
    for (int b = a + 1; b <= 100; ++b)
      if ((a + 50) % b == u)
        p.push_back({a, b});
        
  int y = 1;
  unordered_map<int, pair<int, int>> m;
  for (; y <= 100; ++y) {
    for (const auto& [a, b] : p)
      m[(a + y) % b] = {a, b};
    if (m.size() == p.size()) break;
    else m.clear();
  }
  cout << "? " << y << endl;
  int w;
  cin >> w;
  cout << "! " << m[w].first << " " << m[w].second << endl;
  
  return 0;
}

0