結果
問題 | No.2948 move move rotti |
ユーザー |
![]() |
提出日時 | 2024-10-26 03:27:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 564 ms / 4,000 ms |
コード長 | 2,996 bytes |
コンパイル時間 | 7,664 ms |
コンパイル使用メモリ | 330,760 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-26 03:27:18 |
合計ジャッジ時間 | 15,354 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace atcoder; using namespace __gnu_pbds; using mint = modint998244353; #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define print(var) std::cout<<#var<<"="<<(var)<<std::endl #define all(a) (a).begin(), (a).end() #define vi vector<int> #define vvi vector<vi> #define vvvi vector<vvi> #define ll long long #define vll vector<ll> #define vvll vector<vll> #define vvvll vector<vvll> #define vvvvll vector<vvvll> #define vmi vector<mint> #define vvmi vector<vmi> #define vvvmi vector<vvmi> #define vvvvmi vector<vvvmi> #define vvvvvmi vector<vvvvmi> #define vs vector<string> #define pii pair<int,int> #define vpii vector<pii> #define vvpii vector<vpii> #define bit(x,i)(((x)>>(i))&1) #define inf (1<<30) #define INF (1ll<<60) #define X first #define Y second template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } template<class T, class F> T nibutan(T ok, T ng, const F &f){while(abs(ok-ng)>1){T mid = (ok+ng)/2;(f(mid)?ok:ng) = mid;}return ok;} template<class T> vector<T> digit(T x){vector<T> res; while(x>0){res.push_back(x%10); x/=10;} return res;} ostream& operator<<(ostream& os, const mint& x){ os << x.val(); return os; } template<class T> istream &operator>>(istream &is, vector<T> &vec){ for(auto &v:vec) is >> v; return is; } template<class T> void coutvector(vector<T> x){ for(int i=0;i<(int)x.size();i++){if(i>0) cout<<" ";cout<<x[i];}cout<<endl;} using Set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; template<class S, class T> using Unordered_Map = gp_hash_table<S,T>; #ifdef LOCAL #include<dump.hpp> CPP_DUMP_DEFINE_EXPORT_OBJECT(mint,val()); #else #define cpp_dump #endif int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,m,k; cin>>n>>m>>k; vi x(k); cin>>x; for(int i=0;i<k;i++) x[i]--; vvi g(n); vi u(m),v(m); for(int i=0;i<m;i++){ int u,v; cin>>u>>v; u--,v--; g[u].push_back(v); g[v].push_back(u); } vvi cnt(n,vi(n,0)); for(int u=0;u<n;u++){ vvi dp(n,vi(1<<n,0)); dp[u][1<<u] = 1; for(int S=0;S<(1<<n);S++){ for(int j=0;j<n;j++){ for(auto v:g[j]){ if(bit(S,v) || !bit(S,j)) continue; dp[v][S|(1<<v)] |= dp[j][S]; } } } for(int i=0;i<n;i++){ for(int S=0;S<(1<<n);S++){ if(!dp[i][S]) continue; cnt[__popcount(S)-1][i] |= 1<<u; } } } bool ans = false; int mask = 0; for(int i=0;i<k;i++) mask |= 1<<x[i]; for(int i=0;i<n;i++)for(int j=0;j<n;j++){ ans |= __popcount(cnt[i][j] & mask) == __popcount(mask); } Yes(ans); }