結果
問題 |
No.2357 Guess the Function
|
ユーザー |
|
提出日時 | 2025-09-27 05:59:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 1,000 ms |
コード長 | 1,534 bytes |
コンパイル時間 | 2,844 ms |
コンパイル使用メモリ | 280,384 KB |
実行使用メモリ | 25,972 KB |
平均クエリ数 | 3.00 |
最終ジャッジ日時 | 2025-09-27 06:00:02 |
合計ジャッジ時間 | 5,434 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:58:17: warning: ‘y’ may be used uninitialized [-Wmaybe-uninitialized] 58 | int ay = Ask(y); | ~~~^~~ main.cpp:52:9: note: ‘y’ was declared here 52 | int y; | ^
ソースコード
// #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #include <bits/stdc++.h> using std::cin, std::cout, std::cerr; using ll = long long; bool Check(int x, int ax, int y) { std::set<int> set; for(int i = 0; i < 100; i ++) for(int j = i + 1; j <= 100; j ++) if((i + x) % j == ax) { int ay = (i + y) % j; if(set.count(ay)) return false; set.insert(ay); } return true; } int Ask(int x) { cout << "? " << x << '\n'; cout.flush(); int a; cin >> a; return a; } void Answer(int a, int b) { cout << "! " << a << ' ' << b << '\n'; cout.flush(); } int main() { std::ios::sync_with_stdio(false); // for(int x = 1; x <= 100; x ++) { // bool ok = true; // for(int ax = 0; ax < 100; ax ++) { // bool f = false; // for(int y = 1; y <= 100; y ++) { // if(Check(x, ax, y)) { // f = true; // break; // } // } // if(!f) ok = false; // } // if(ok) // cout << x << '\n'; // } int x = 100; int ax = Ask(x); int y; for(int i = 1; i <= 100; i ++) if(Check(x, ax, i)) { y = i; break; } int ay = Ask(y); for(int a = 0; a < 100; a ++) for(int b = a + 1; b <= 100; b ++) if((x + a) % b == ax && (y + a) % b == ay) Answer(a, b); }