結果
問題 | No.355 数当てゲーム(2) |
ユーザー |
![]() |
提出日時 | 2024-02-24 15:10:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 2,359 bytes |
コンパイル時間 | 5,513 ms |
コンパイル使用メモリ | 319,068 KB |
実行使用メモリ | 25,488 KB |
平均クエリ数 | 100.00 |
最終ジャッジ日時 | 2024-09-29 10:02:18 |
合計ジャッジ時間 | 13,056 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#include <bits/stdc++.h> using namespace std; using namespace chrono; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif int main() { random_device rnd; mt19937 engine(rnd()); uniform_int_distribution<> rand10(0, 9); vector<vector<int64_t>> qss; vector<pair<int64_t, int64_t>> rs; for (int64_t i = 0; i < 99; i++) { vector<int64_t> qs(4); qs[0] = rand10(engine); do { qs[1] = rand10(engine); } while (qs[1] == qs[0]); do { qs[2] = rand10(engine); } while (qs[2] == qs[0] || qs[2] == qs[1]); do { qs[3] = rand10(engine); } while (qs[3] == qs[0] || qs[3] == qs[1] || qs[3] == qs[2]); qss.push_back(qs); for (auto &&q : qs) { cout << q << ' '; } cout << endl; int64_t x, y; cin >> x >> y; rs.push_back({x, y}); if (x == 4 && y == 0) { return 0; } } auto f = [](vector<int64_t> qs, vector<int64_t> ns) { pair<int64_t, int64_t> ret(0, 0); for (int64_t i = 0; i < qs.size(); i++) { if (qs[i] == ns[i]) { ret.first++; } for (int64_t j = 0; j < qs.size(); j++) { if (i == j) { continue; } if (qs[i] == ns[j]) { ret.second++; } } } return ret; }; for (int64_t a = 0; a <= 9; a++) { for (int64_t b = 0; b <= 9; b++) { for (int64_t c = 0; c <= 9; c++) { for (int64_t d = 0; d <= 9; d++) { vector<int64_t> ns({a, b, c, d}); bool flag = true; for (int64_t i = 0; i < qss.size(); i++) { flag &= f(qss[i], ns) == rs[i]; } if (flag) { cout << a << ' ' << b << ' ' << c << ' ' << d << endl; return 0; } } } } } return 0; }