이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |