結果
| 問題 | No.3275 Minesweeper on Graph | 
| コンテスト | |
| ユーザー |  沙耶花 | 
| 提出日時 | 2025-09-19 21:23:31 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 9 ms / 2,000 ms | 
| コード長 | 853 bytes | 
| コンパイル時間 | 3,795 ms | 
| コンパイル使用メモリ | 253,504 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-09-19 21:23:40 | 
| 合計ジャッジ時間 | 7,290 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 40 | 
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000005
#define Inf64 1000000000000000001LL
int main(){
	
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	
	vector<vector<int>> E(n);
	rep(i,m){
		int u,v;
		cin>>u>>v;
		u--;v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	rep(i,1<<n){
		vector<int> c(n);
		rep(j,n){
			if(i&(1<<j)){
				c[j] = 1;
			}
		}
		
		bool ok = true;
		rep(j,n){
			int cc = 0;
			rep(k,E[j].size()){
				int to = E[j][k];
				if(c[to])cc++;
			}
			if(cc != a[j]){
				ok = false;
				break;
			}
		}
		if(ok){
			cout<<"Yes"<<endl;
			rep(j,n){
				if(j!=0)cout<<' ';
				cout<<c[j];
			}
			cout<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	
}
            
            
            
        