Submission #208584

#TimeUsernameProblemLanguageResultExecution timeMemory
208584DodgeBallManCities (BOI16_cities)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pii pair<long long, long long> #define x first #define y second using namespace std; const int N = 1e5 + 2; vector<pii> g[N]; vector<int> bit[10]; long long d[N][1<<5], ans = 1e18; int n, k, m, id[N]; int main() { memset( id, -1, sizeof id ); fill( d[0], d[0]+N*(1<<5), ans ); scanf("%d %d %d",&n,&k,&m); for( int i = 0, a ; i < k ; i++ ) { scanf("%d",&a); id[a] = i; } for( int i = 0, a, b ; i < m ; i++ ) { long long d; scanf("%d %d %lld",&a,&b,&d); g[a].emplace_back( pii( b, d ) ), g[b].emplace_back( pii( a, d )); } for( int i = 1 ; i < ( 1 << k ) ; i++ ){ bit[__builtin_popcount( i )].emplace_back( i ); } for( int b = 1 ; b <= k ; b++ ) { priority_queue<pair<long long, pii>> q; if( b == 1 ) { for( int i = 1 ; i <= n ; i++ ) if( id[i] != -1 ) q.emplace( d[i][(1<<id[i])] = 0, pii( i, (1<<id[i] ) ) ); } else { for( int i = 1 ; i <= n ; i++ ) for( int x : bit[b] ) { for( int j = 0 ; j < ( 1 << k ) ; j++ ) { if( ( x & j ) != j ) continue ; d[i][x] = min( d[i][x], d[i][j] + d[i][x^j] ); q.emplace( -1*d[i][x], pii( i, x ) ); } } } while( !q.empty() ) { auto now = q.top(); q.pop(); if( d[now.y.x][now.y.y] != -now.x ) continue; long long di = -now.x; int u = now.y.x, bi = now.y.y; for( pil v : g[u] ) if( d[v.x][bi] > di + v.y ) { d[v.x][bi] = di + v.y; q.emplace( -1*d[v.x][bi], pii( v.x, bi ) ); } } } for( int i = 0 ; i < n ; i++ ) ans = min( ans, d[i][(1<<k)-1] ); printf("%lld",ans); return 0; }

Compilation message (stderr)

cities.cpp: In function 'int main()':
cities.cpp:50:18: error: 'pil' was not declared in this scope
             for( pil v : g[u] ) if( d[v.x][bi] > di + v.y ) {
                  ^~~
cities.cpp:50:18: note: suggested alternative: 'pii'
             for( pil v : g[u] ) if( d[v.x][bi] > di + v.y ) {
                  ^~~
                  pii
cities.cpp:54:9: error: expected primary-expression before '}' token
         }
         ^
cities.cpp:54:9: error: expected ';' before '}' token
cities.cpp:54:9: error: expected primary-expression before '}' token
cities.cpp:54:9: error: expected ')' before '}' token
cities.cpp:54:9: error: expected primary-expression before '}' token
cities.cpp:48:24: warning: unused variable 'di' [-Wunused-variable]
             long  long di = -now.x;
                        ^~
cities.cpp:49:17: warning: unused variable 'u' [-Wunused-variable]
             int u = now.y.x, bi = now.y.y;
                 ^
cities.cpp:49:30: warning: unused variable 'bi' [-Wunused-variable]
             int u = now.y.x, bi = now.y.y;
                              ^~
cities.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&k,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
cities.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a);
         ~~~~~^~~~~~~~~
cities.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %lld",&a,&b,&d);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~