結果

問題 No.3275 Minesweeper on Graph
ユーザー kotatsugame
提出日時 2025-09-21 12:09:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 62,676 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-21 12:09:36
合計ジャッジ時間 4,412 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
int N;
int G[16],A[16];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int M;
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;u--,v--;
		G[u]|=1<<v;
		G[v]|=1<<u;
	}
	for(int X=0;X<1<<N;X++)
	{
		bool ok=true;
		for(int i=0;i<N;i++)if(__builtin_popcount(X&G[i])!=A[i])
		{
			ok=false;
			break;
		}
		if(ok)
		{
			cout<<"Yes\n";
			for(int i=0;i<N;i++)cout<<(X>>i&1)<<(i+1==N?"\n":" ");
			return 0;
		}
	}
	cout<<"No\n";
}
0