結果

問題 No.3275 Minesweeper on Graph
ユーザー ripity
提出日時 2025-09-19 22:29:36
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 3,268 ms
コンパイル使用メモリ 282,008 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-09-19 22:29:43
合計ジャッジ時間 7,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<vector<int>> G(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int s = 0; s < 1 << N; s++) {
        vector<int> B(N);
        for(int i = 0; i < N; i++) {
            for(int j : G[i]) B[j] += (s >> i) & 1;
        }
        if(A == B) {
            cout << "Yes" << endl;
            for(int i = 0; i < N; i++) {
                cout << ((s >> i) & 1) << " \n"[i == N - 1];
            }
            return 0;
        }
    }
    cout << "No" << endl;
}
0