結果
| 問題 | No.3275 Minesweeper on Graph | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-09-19 21:25:50 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 2,000 ms | 
| コード長 | 1,097 bytes | 
| コンパイル時間 | 1,801 ms | 
| コンパイル使用メモリ | 198,572 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-09-19 21:25:56 | 
| 合計ジャッジ時間 | 5,530 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 40 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b;
int A[16];
vector <int> adj[16];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> n >> m;
    for(int i=0;i<n;i++) cin >> A[i];
    for(int i=0;i<m;i++)
    {
        cin >> a >> b;
        a-=1;
        b-=1;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=0;i<(1<<n);i++)
    {
        int res[16];
        memset(res,0,sizeof(res));
        for(int j=0;j<n;j++)
        {
            if((i&(1<<j))) res[j] = 1;
        }
        bool ok = true;
        for(int j=0;j<n;j++)
        {
            int cnt = 0;
            for(auto k : adj[j])
            {
                cnt += res[k];
            }
            if(cnt!=A[j])
            {
                ok = false;
                break;
            }
        }
        if(ok)
        {
            cout << "Yes" << '\n';
            for(int j=0;j<n;j++)
            {
                cout << res[j] << ' ';
            }
            cout << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
	return 0;
}
            
            
            
        