제출 #1006108

#제출 시각아이디문제언어결과실행 시간메모리
1006108pudelosPaths (BOI18_paths)C++17
100 / 100
388 ms97280 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i=a; i<=b; ++i) #define eb emplace_back #define ll long long #define V vector const int maxn=3e5+7, maxk=5; ll dp[maxn][1<<maxk]; int n, m, k; V<int> A; V<V<int>> con; int main() { cin.tie(0) -> ios_base::sync_with_stdio(0); cin >> n >> m >> k; A.resize(n+1); con.resize(n+1); FOR(i, 1, n) { cin >> A[i]; --A[i]; dp[i][1<<A[i]]=1; } int a, b; FOR(i, 1, m) { cin >> a >> b; con[a].eb(b); con[b].eb(a); } ll odp=0; FOR(m, 1, (1<<k)-1) { FOR(v, 1, n) { int gr = A[v]; if(m&(1<<gr)==0) continue; if(__builtin_popcount(m)>=2) odp+=dp[v][m]; for(int u : con[v]) { int sgr = A[u]; if(m&(1<<sgr)==1) continue; dp[u][m^(1<<sgr)]+=dp[v][m]; } } } cout << odp << '\n'; }

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

paths.cpp: In function 'int main()':
paths.cpp:35:19: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   35 |       if(m&(1<<gr)==0) continue;
      |            ~~~~~~~^~~
paths.cpp:39:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   39 |         if(m&(1<<sgr)==1) 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...