結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2024-10-26 18:35:37 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,312 bytes |
| コンパイル時間 | 3,598 ms |
| コンパイル使用メモリ | 259,492 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-26 18:35:43 |
| 合計ジャッジ時間 | 5,452 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 4 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
#ifdef _MSC_VER
#define __builtin_popcount (int)__popcnt
#define __builtin_popcountll (int)__popcnt64
inline int __builtin_ctz(unsigned int n) { unsigned long i; _BitScanForward(&i, n); return i; }
inline int __builtin_ctzll(unsigned long long n) { unsigned long i; _BitScanForward64(&i, n); return i; }
inline int __builtin_clz(unsigned int n) { unsigned long i; _BitScanReverse(&i, n); return i; }
inline int __builtin_clzll(unsigned long long n) { unsigned long i; _BitScanReverse64(&i, n); return i; }
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k; cin >> n >> m >> k;
vector<int>x(k);
rep(i, k)cin >> x[i], x[i]--;
vector to(n, vector<int>());
rep(i, m) {
int a, b; cin >> a >> b;
a--, b--;
to[a].push_back(b);
to[b].push_back(a);
}
// dp[i][j][k]:= iがjにいて、集合がk
vector dp(k, vector(n, vector<bool>(1 << n)));
rep(i, k) dp[i][x[i]][1 << x[i]] = true;
rep(i, k)rep(j, n)rep(k, 1 << n) {
if (!dp[i][j][k])continue;
int ni = i;
for (auto nj : to[j]) {
if (1 & (k >> nj))continue;
int nk = k + (1 << nj);
dp[ni][nj][nk] = true;
}
}
vector bit(n + 1, vector<int>(n));//turn pos
rep(i, k)rep(j, n)rep(k, 1 << n) {
if (!dp[i][j][k])continue;
int pc = __builtin_popcount(k);
bit[pc][j] += 1 << i;
}
bool chk = false;
rep(i, n + 1) rep(j, n) {
if ((1 << k) - 1 == bit[i][j])chk = true;
//cout << i << " " << j << " " << bit[i][j] << endl;
}
cout << (chk ? "Yes" : "No") << endl;
return 0;
}
kwm_t