제출 #648152

#제출 시각아이디문제언어결과실행 시간메모리
648152jcelinPaths (BOI18_paths)C++14
100 / 100
426 ms57728 KiB
#include <bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef unsigned int ui; #define ii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vii vector<ii> #define vll vector<ll> #define vpll vector<pll> #define matrix vector<vi> #define matrixLL vector<vll> #define vs vector<string> #define vui vector<ui> #define msi multiset<int> #define mss multiset<string> #define si set<int> #define ss set<string> #define PB push_back #define PF push_front #define PPB pop_back #define PPF pop_front #define X first #define Y second #define MP make_pair #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() const int dx[] = {-1, 1, 0, 0}; const int dy[] = {0, 0, -1, 1}; const int dxx[] = {-1, 1, 0, 0, 1, 1, -1, -1}; const int dyy[] = {0, 0, -1, 1, -1, 1, -1, 1}; const string abc="abcdefghijklmnopqrstuvwxyz"; const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const ld pi = 3.14159265; const int mod = 1e9 + 7; const int MOD = 1e9 + 7; const int MAXN = 3e5 + 7; const int inf = mod; const ll INF = 1e18; const ll zero = ll(0); const int logo = 5; const int off = 1 << logo; const int trsz = off << 1; ll n, m, k; ll arr[MAXN], dp[off][MAXN], ans; vi g[MAXN]; void solve(){ cin >> n >> m >> k; for(int i = 1; i <= n; i++) cin >> arr[i], arr[i]--; for(int i = 1, a, b; i <= m; i++) cin >> a >> b, g[a].PB(b), g[b].PB(a); for(ll x = 1; x < (1 << k); x++) for(ll i = 1; i <= n; i++){ if(x & (1 << arr[i]) == 0) continue; ll j = (1 << arr[i]); if(j == x) dp[x][i] = 1; for(auto &y : g[i]) dp[x][i] += dp[x ^ j][y]; ans += dp[x][i]; } cout << ans - n << "\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t=1; //cin >> t; while(t--)solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

paths.cpp: In function 'void solve()':
paths.cpp:65:24: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   65 |   if(x & (1 << arr[i]) == 0) continue;
      |          ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...