結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-25 22:54:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 3,257 ms |
| コンパイル使用メモリ | 198,796 KB |
| 最終ジャッジ日時 | 2025-02-24 23:43:03 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | AC * 3 RE * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main () {
int N, M, K;
cin >> N >> M >> K;
std::vector<int> X(K);
for (auto& x : X) {
cin >> x;
x --;
}
vector<vector<int>> gr(N);
while (M) {
int a, b;
cin >> a >> b;
gr[--a].push_back(--b);
}
int cg[15][15];
for (int b = 0; b < N; b ++) {
cg[b][0] = (1 << b);
for (int i = 1; i < N; i ++) cg[b][i] = 0;
vector dp((1 << N), vector<int>(N, 0));
dp[1 << b][b] = 1;
for (int s = (1 << b); s < (1 << N); s ++) {
for (int i = 0; i < N; i ++) {
if (!dp[s][i]) continue;
int n = 0;
for (int p = 0; p < N; p ++) n += ((s >> p) & 1);
cg[b][n-1] |= (1 << i);
for (auto& v : gr[i]) {
if (!((s >> v) & 1)) {
dp[s ^ (1 << v)][v] = 1;
}
}
}
}
}
for (int d = 0; d < N; d ++) {
int x = (1 << N) - 1;
for (auto& k : X) {
x &= cg[k][d];
}
if (x) {
puts("Yes");
return 0;
}
}
puts("No");
}