結果

問題 No.3275 Minesweeper on Graph
ユーザー GOTKAKO
提出日時 2025-09-20 00:59:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 1,800 ms
コンパイル使用メモリ 200,844 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-20 00:59:41
合計ジャッジ時間 5,556 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    int N,M; cin >> N >> M;
    vector<int> A(N);
    for(auto &a : A) cin >> a;
    vector<vector<int>> Graph(N);
    for(int i=0; i<M; i++){
        int u,v; cin >> u >> v;
        u--; v--;
        Graph.at(u).push_back(v);
        Graph.at(v).push_back(u);
    }

    vector<int> X(N),C(N);
    auto dfs = [&](auto dfs,int pos) -> void {
        if(A == C){
            cout << "Yes\n";
            for(auto x : X) cout << x << " "; cout << endl;
            exit(0);
        }
        if(pos == N) return;
        X.at(pos) = 0,dfs(dfs,pos+1);
        for(auto to : Graph.at(pos)) C.at(to)++;
        X.at(pos) = 1,dfs(dfs,pos+1);
        for(auto to : Graph.at(pos)) C.at(to)--;
        X.at(pos) = 0;
    };
    dfs(dfs,0);
    cout << "No\n";
}

 
0