Submission #975648

#TimeUsernameProblemLanguageResultExecution timeMemory
975648IsamPaths (BOI18_paths)C++17
53 / 100
92 ms65132 KiB
#include<bits/stdc++.h> using namespace std; #define eb emplace_back #define int long long constexpr int sz = 2e5 + 5; int n, m, k, ans, c[sz]; vector<int> g[sz]; int dp[sz][33]; int dfs(int node, int co){ if(dp[node][co] != -1) return dp[node][co]; dp[node][co] = (__builtin_popcount(co) > 1); for(auto &to : g[node]){ if(co & (1 << c[to])) continue; dp[to][co | (1 << c[to])] = dfs(to, co | (1 << c[to])); } for(auto &to : g[node]){ if(co & (1 << c[to])) continue; dp[node][co] += dp[to][co | (1 << c[to])]; } return dp[node][co]; } signed main(){ ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> m >> k; for(register int i = 1; i <= n; ++i){ cin >> c[i]; c[i]--; } for(register int i = 1, u, v; i <= m; ++i){ cin >> u >> v; g[u].eb(v), g[v].eb(u); } memset(dp, -1, sizeof(dp)); for(register int i = 1; i <= n; ++i){ dp[i][1 << c[i]] = dfs(i, (1 << c[i])); ans += dp[i][1 << c[i]]; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

paths.cpp: In function 'int main()':
paths.cpp:47:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   47 |  for(register int i = 1; i <= n; ++i){
      |                   ^
paths.cpp:52:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |  for(register int i = 1, u, v; i <= m; ++i){
      |                   ^
paths.cpp:52:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |  for(register int i = 1, u, v; i <= m; ++i){
      |                          ^
paths.cpp:52:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |  for(register int i = 1, u, v; i <= m; ++i){
      |                             ^
paths.cpp:59:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |  for(register int i = 1; i <= n; ++i){
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...