結果
問題 |
No.2948 move move rotti
|
ユーザー |
|
提出日時 | 2024-11-22 16:46:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 159 ms / 4,000 ms |
コード長 | 1,189 bytes |
コンパイル時間 | 3,683 ms |
コンパイル使用メモリ | 257,504 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 16:46:59 |
合計ジャッジ時間 | 6,583 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#ifndef LOCAL #include <bits/stdc++.h> using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif void solve() { int N, M, K; cin >> N >> M >> K; vector<int> X(K); for (int i = 0; i < K; i++) cin >> X[i], X[i]--; vector<vector<int>> G(N); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } const int S = 1 << N; vector<int> res(N, S - 1); for(int t = 0; t < K; t++) { vector<vector<bool>> dp(N, vector<bool>(S)); dp[X[t]][1 << (X[t])] = 1; vector<int> T(N); for(int s = 0; s < S; s++) for(int i = 0; i < N; i++) if(dp[i][s]) { T[std::popcount((unsigned)s) - 1] |= 1 << i; for(int nv: G[i]) if(!(s >> nv & 1)) dp[nv][s | (1 << nv)] = 1; } for(int i = 0; i < N; i++) res[i] &= T[i]; } for(int i = 0; i < N; i++) if(res[i]) { cout << "Yes\n";return; } cout << "No\n"; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }