| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1343877 | Zero | Palembang Bridges (APIO15_bridge) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second
#define pi pair<int,int>
signed main(){
cin.tie(0)->sync_with_stdio(0);
int k, n; cin >> k >> n;
int cn = 0, s = 0;
vector<int> x,y;
for(int i=0; i < n; i ++){
char a,b; int a1, b1; cin >> a >> a1 >> b >> b1;
if(a == b) s += abs(a1 - b1);
else x.pb(a1), y.pb(b1), cn ++;
}
int mn = INT_MAX;
for(int i=0; i < cn; i ++){
for(int j=i+1; j < cn; j ++){
int cr = s;
for(int h = 0; h < cn; h ++){
int t = min(abs(x[h] - x[i]) + abs(y[h] - x[i]) + 1, abs(x[h] - x[j]) + abs(y[h] - x[j]) + 1);
cr += t;
}
mn = min(mn, cr);
}
}
cout << mn;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
