結果

問題 No.624 Santa Claus and The Last Dungeon
コンテスト
ユーザー vjudge1
提出日時 2026-03-23 11:27:12
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 3,328 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,570 ms
コンパイル使用メモリ 165,636 KB
実行使用メモリ 28,988 KB
平均クエリ数 401.00
最終ジャッジ日時 2026-03-23 11:27:33
合計ジャッジ時間 12,937 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

vector<int> adj[100];
int match_to[100];
bool visited[100];

bool dfs(int u) {
    for (int v : adj[u]) {
        if (!visited[v]) {
            visited[v] = true;
            if (match_to[v] == -1 || dfs(match_to[v])) {
                match_to[v] = u;
                return true;
            }
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Q;
    cin >> Q;
    
    int cnt1[10][10] = {0};
    int cnt2[10][10] = {0};
    int cnt1u[10][10] = {0};
    int cnt2u[10][10] = {0};
    
    for (int g1 = 0; g1 < 10; ++g1) {
        for (int x = 0; x < 10; ++x) {
            for (int i = 0; i < 100; ++i) {
                if (i / 10 == g1) {
                    cout << (char)('0' + x) << "? ";
                } else {
                    cout << "?? ";
                }
            }
            cout << '\n';
            cout.flush();
            int p0, p1, p2;
            cin >> p0 >> p1 >> p2;
            cnt1[g1][x] = p1;
        }
    }
    
    for (int g1 = 0; g1 < 10; ++g1) {
        for (int y = 0; y < 10; ++y) {
            for (int i = 0; i < 100; ++i) {
                if (i / 10 == g1) {
                    cout << "?" << (char)('0' + y) << " ";
                } else {
                    cout << "?? ";
                }
            }
            cout << '\n';
            cout.flush();
            int p0, p1, p2;
            cin >> p0 >> p1 >> p2;
            cnt2[g1][y] = p1;
        }
    }
    
    for (int g2 = 0; g2 < 10; ++g2) {
        for (int x = 0; x < 10; ++x) {
            for (int i = 0; i < 100; ++i) {
                if (i % 10 == g2) {
                    cout << (char)('0' + x) << "? ";
                } else {
                    cout << "?? ";
                }
            }
            cout << '\n';
            cout.flush();
            int p0, p1, p2;
            cin >> p0 >> p1 >> p2;
            cnt1u[g2][x] = p1;
        }
    }
    
    for (int g2 = 0; g2 < 10; ++g2) {
        for (int y = 0; y < 10; ++y) {
            for (int i = 0; i < 100; ++i) {
                if (i % 10 == g2) {
                    cout << "?" << (char)('0' + y) << " ";
                } else {
                    cout << "?? ";
                }
            }
            cout << '\n';
            cout.flush();
            int p0, p1, p2;
            cin >> p0 >> p1 >> p2;
            cnt2u[g2][y] = p1;
        }
    }
    
    for (int x = 0; x < 10; ++x) {
        for (int y = 0; y < 10; ++y) {
            int u = x * 10 + y;
            for (int i = 0; i < 100; ++i) {
                int g1 = i / 10;
                int g2 = i % 10;
                if (cnt1[g1][x] > 0 && cnt2[g1][y] > 0 && cnt1u[g2][x] > 0 && cnt2u[g2][y] > 0) {
                    adj[u].push_back(i);
                }
            }
        }
    }
    
    memset(match_to, -1, sizeof(match_to));
    for (int u = 0; u < 100; ++u) {
        memset(visited, 0, sizeof(visited));
        dfs(u);
    }
    
    for (int i = 0; i < 100; ++i) {
        int val = match_to[i];
        cout << (char)('0' + (val / 10)) << (char)('0' + (val % 10)) << " ";
    }
    cout << '\n';
    cout.flush();
    
    int p0, p1, p2;
    cin >> p0 >> p1 >> p2;
    
    return 0;
}
0