結果
| 問題 |
No.3275 Minesweeper on Graph
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-09-20 13:12:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 996 bytes |
| コンパイル時間 | 558 ms |
| コンパイル使用メモリ | 57,492 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-09-20 13:12:17 |
| 合計ジャッジ時間 | 4,306 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:32:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | for (int i = 0; i < n; i++) scanf("%d", as + i);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d%d", &u, &v);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3275.cc: No.3275 Minesweeper on Graph - yukicoder
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 16;
/* typedef */
using vi = vector<int>;
/* global variables */
int as[MAX_N];
vi nbrs[MAX_N];
/* subroutines */
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", as + i);
for (int i = 0; i < m; i++) {
int u, v;
scanf("%d%d", &u, &v);
u--, v--;
nbrs[u].push_back(v);
nbrs[v].push_back(u);
}
int nbits = 1 << n;
for (int bits = 0; bits < nbits; bits++) {
bool ok = true;
for (int u = 0; ok && u < n; u++) {
int sum = 0;
for (auto v: nbrs[u]) sum += ((bits >> v) & 1);
ok = (sum == as[u]);
}
if (ok) {
puts("Yes");
for (int i = 0; i < n; i++)
printf("%d%c", (bits >> i) & 1, (i + 1 < n) ? ' ' : '\n');
return 0;
}
}
puts("No");
return 0;
}
tnakao0123