이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000000000000000ll
#define int long long
struct data{
char t1, t2;
int x1, x2;
};
signed main() {
int k, n; cin >> k >> n;
vector<int> arr;
vector<data> v(n);
for (int i = 0; i < n; ++i){
char t1, t2; int x1, x2;
cin >> t1 >> x1 >> t2 >> x2;
v[i] = {t1, t2, x1, x2};
if (t1 != t2) arr.push_back(x1), arr.push_back(x2);
}
int ans = oo;
for (int i = 0; i < arr.size(); ++i){
for (int j = i+1; j < arr.size(); ++j){
int cur = 0;
for (int x = 0; x < n; ++x){
if (v[x].t1 == v[x].t2) cur += abs(v[x].x1 - v[x].x2);
else{
int c = abs(v[x].x1 - arr[i]) + abs(v[x].x2 - arr[i]) + 1;
c = min(c, abs(v[x].x1 - arr[j]) + abs(v[x].x2 - arr[j]) + 1);
cur += c;
}
}
ans = min(ans, cur);
}
}
cout << ans << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bridge.cpp: In function 'int main()':
bridge.cpp:25:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int i = 0; i < arr.size(); ++i){
| ~~^~~~~~~~~~~~
bridge.cpp:26:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int j = i+1; j < arr.size(); ++j){
| ~~^~~~~~~~~~~~
# | 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... |