結果

問題 No.3275 Minesweeper on Graph
コンテスト
ユーザー Facade
提出日時 2025-10-19 15:26:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 2,849 ms
コンパイル使用メモリ 281,932 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-19 15:26:26
合計ジャッジ時間 7,562 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e18;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;cin>>n>>m;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<vector<int>>connect(n);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        connect[a].push_back(b);
        connect[b].push_back(a);
    }
    for(int bit=0;bit<(1LL<<n);bit++){
        vector<int>cnt(n,0);
        for(int i=0;i<n;i++){
            for(int j:connect[i]){
                cnt[i]+=(bit>>j)&1;
            }
        }
        if(cnt==a){
            cout<<"Yes\n";
            for(int i=0;i<n;i++)cout<<((bit>>i)&1)<<" ";cout<<endl;
            return 0;
        }
    }
    cout<<"No\n";
}
0