結果

問題 No.3275 Minesweeper on Graph
ユーザー daiota
提出日時 2025-09-19 22:16:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 930 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 173,644 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-19 22:16:18
合計ジャッジ時間 5,363 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)














int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;



	ll N,M;
	cin >> N >> M;

	vector<ll> a(N+1);
	for(i=1;i<=N;i++) cin >> a[i];

	map<ll,vector<ll>> m;
	for(i=1;i<=M;i++){

		ll U,V;
		cin >> U >> V;

		m[U].push_back(V);
		m[V].push_back(U);
	}


	vector<ll> ans;
	for(i=0;i<(1LL<<N);i++){
		vector<ll> d(N+1,0);
		for(j=0;j<N;j++) if(i&(1LL<<j)) d[j+1]=1;

		bool f=true;
		for(auto x:m){

			ll p=x.first;
			vector<ll> v=x.second;
			ll n=v.size();
			ll s=0;
			REP(k,n) s+=d[v[k]];

			if(a[p]!=s){
				f=false;
				break;
			}

		}

		if(f){
			ans=d;
			break;
		}

	}


	if((ll)ans.size()==0) cout << "No" << endl;
	else{
		cout << "Yes" << endl;

		for(i=1;i<=N;i++) cout << ans[i] << ' ';
		cout << endl;

	}











	return 0;

}





0