Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
using namespace std; int main() { ios_base::sync_with_stdio(0); int mat[4][4] = {{0, 10, 15, 20}, {10, 0, 35, 25}, {15, 35, 0 ,30}, {20, 25, 30, 0} }; int arr[] = {0, 1, 2, 3}; int min_cost = 2e9; do { int cost = 0; for(int i = 0; i < 3; i++) { cost += mat[arr[i]][arr[i + 1]]; } cost += mat[arr[3]][arr[0]]; min_cost = min(min_cost, cost); } while(next_permutation(arr, arr + 4)); cout << min_cost << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)