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
using namespace std;
struct ppl {
ll h,o; //house, office
};
ll n,m,k,x,y,z;
vector<ll> median;
vector<ppl> city;
char st, ed;
ll cal(vector<ppl> & city, vector<ll> & median) {
ll ans = 0;
sort(median.begin(),median.end());
if (median.size()) {
ll bridge = median[median.size()/2];
for (auto i : city) ans += abs(i.h-bridge) + abs(i.o-bridge) + 1;
}
return ans;
}
void sub1() {
ll ans = 0;
for (int i = 1; i <= n; i++) {
cin >> st >> x >> ed >> y;
if (st == ed) ans += abs(x-y);
else {
median.push_back(x);
median.push_back(y);
city.push_back({x,y});
}
}
cout << ans + cal(city,median) << "\n";
}
void sub2() {
cout << "oh no :(";
}
signed main() {
cin >> m >> n;
if (m == 1) sub1();
else sub2();
}
# | 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... |