Submission #45082

#TimeUsernameProblemLanguageResultExecution timeMemory
45082nibnalinCities (BOI16_cities)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int lli; const int maxn = lli(1e5)+5, maxk = 6; const lli inf = lli(1e17)+5; int n, A[maxk]; lli D[maxk][maxn], dp[(1<<maxk)][maxn]; vector<pair<int, lli>> graph[maxn]; void read(int &res) { res=0; while(*buffp<48) ++buffp; while(*buffp>47) res=(res<<3)+(res<<1)+*buffp++-48; } int main(void) { int k, m, u, v; lli w; read(n); read(k); read(m); for(int i = 0;i < k;i++) { read(A[i]); A[i]--; } for(int i = 0;i < m;i++) { read(u); read(v); read(w); u--, v--; graph[u].push_back({v, w}), graph[v].push_back({u, w}); } for(int i = 0;i < (1<<k);i++) { for(int j = 0;j < n;j++) dp[i][j] = inf; } for(int i = 0;i < k;i++) dp[(1<<i)][A[i]] = 0; for(int mask = 1;mask < (1<<k);mask++) { priority_queue<pair<lli, int>> Q; for(int i = 0;i < n;i++) { for(int j = 0;j < k;j++) { if((mask&(1<<j))) dp[mask][i] = min(dp[mask][i], dp[(mask^(1<<j))][i]+dp[(1<<j)][i]); } Q.push({-dp[mask][i], i}); } while(!Q.empty()) { pair<lli, int> top = Q.top(); Q.pop(); for(auto it: graph[top.second]) { if(dp[mask][it.first] > dp[mask][top.second]+it.second) { dp[mask][it.first] = dp[mask][top.second]+it.second; Q.push({-dp[mask][it.first], it.first}); } } } } lli res = inf; for(int i = 0;i < n;i++) res = min(res, dp[(1<<k)-1][i]); printf("%lld\n", res); }

Compilation message (stderr)

cities.cpp: In function 'void read(int&)':
cities.cpp:15:9: error: 'buffp' was not declared in this scope
  while(*buffp<48) ++buffp;
         ^~~~~
cities.cpp:16:9: error: 'buffp' was not declared in this scope
  while(*buffp>47) res=(res<<3)+(res<<1)+*buffp++-48;
         ^~~~~
cities.cpp: In function 'int main()':
cities.cpp:32:27: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   read(u); read(v); read(w);
                           ^
cities.cpp:13:6: note:   initializing argument 1 of 'void read(int&)'
 void read(int &res) {
      ^~~~