87 for( std::uint32_t c = 0 ; c <
NCities ; ++c )
89 ?
double( c_to_bucharest[ c ] )
90 : std::hypot( c_xy[ c ][ 0 ] - c_xy[ to ][ 0 ] ,
91 c_xy[ c ][ 1 ] - c_xy[ to ][ 1 ] ) );
97 [[nodiscard]]
static const char *
name( std::uint32_t c ) {
98 static const char *
const n[
NCities ] = {
99 "Arad" ,
"Bucharest" ,
"Craiova" ,
"Drobeta" ,
"Eforie" ,
"Fagaras" ,
100 "Giurgiu" ,
"Hirsova" ,
"Iasi" ,
"Lugoj" ,
"Mehadia" ,
"Neamt" ,
101 "Oradea" ,
"Pitesti" ,
"Rimnicu" ,
"Sibiu" ,
"Timisoara" ,
"Urziceni" ,
102 "Vaslui" ,
"Zerind" };
104 throw( std::invalid_argument(
"Romania::name: no such city" ) );
110 [[nodiscard]]
static City find(
const std::string & city_name ) {
111 for( std::uint32_t c = 0 ; c <
NCities ; ++c )
112 if( city_name ==
name( c ) )
120 [[nodiscard]]
static const std::array< Road , 23 > &
roads(
void ) {
121 static const std::array< Road , 23 > r = { {
142 static constexpr int c_to_bucharest[
NCities ] = {
143 366 , 0 , 160 , 242 , 161 , 176 , 77 , 151 , 226 , 244 , 241 , 234 , 380 ,
144 100 , 193 , 253 , 329 , 80 , 199 , 374 };
147 static constexpr int c_xy[
NCities ][ 2 ] = {
148 { 91 , 492 } , { 400 , 327 } , { 253 , 288 } , { 165 , 299 } ,
149 { 562 , 293 } , { 305 , 449 } , { 375 , 270 } , { 534 , 350 } ,
150 { 473 , 506 } , { 165 , 379 } , { 168 , 339 } , { 406 , 537 } ,
151 { 131 , 571 } , { 320 , 368 } , { 233 , 410 } , { 207 , 457 } ,
152 { 94 , 410 } , { 456 , 350 } , { 509 , 444 } , { 108 , 531 } };