이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int k, n, mn = LONG_LONG_MAX, sm;
cin >> k >> n;
set<int> st;
vector<pair<pair<char, int>, pair<char, int>>> vec(n);
for (int i = 0; i < n; ++i) {
cin >> vec[i].first.first >> vec[i].first.second >> vec[i].second.first >> vec[i].second.second;
st.insert(vec[i].first.second);
st.insert(vec[i].second.second);
}
for (int i : st) {
sm = 0;
for (int j = 0; j < n; ++j) {
if (vec[j].first.first == vec[j].second.first) sm += abs(vec[j].first.second - vec[j].second.second);
else sm += abs(i - vec[j].second.second) + abs(vec[j].first.second - i) + 1;
}
mn = min(sm, mn);
}
cout << mn;
return 0;
}
# | 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... |