| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 834964 | vjudge1 | Palembang Bridges (APIO15_bridge) | C++17 | 86 ms | 5964 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
const int nmax = 1e5+5;
struct abt {
char har;
int h;
char oar;
int o;
};
abt per[nmax];
int main() {
int K,N;
long long dist = 0;
cin >> K >> N;
vector<pair<int,int>>jar;
vector<int>dex;
for(int i=1; i<=N; i++) {
cin >> per[i].har >> per[i].h >> per[i].oar >> per[i].o;
if(per[i].har == per[i].oar) {
dist += abs(per[i].h - per[i].o);
} else {
jar.push_back({per[i].h, per[i].o});
dex.push_back(per[i].h);
dex.push_back(per[i].o);
}
}
int bridge;
if(jar.empty()) {
cout << dist << endl;
return 0;
}
sort(dex.begin(), dex.end());
int tengah = dex.size()/2;
int tng = dex[tengah];
for(int i=0; i<jar.size(); i++) {
dist += abs(jar[i].fi - tng) + abs(jar[i].se - tng);
}
dist += jar.size();
cout << dist << endl;
return 0;
}
Compilation message (stderr)
| # | 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... | ||||
