結果
| 問題 | No.859 路線A、路線B、路線C |
| コンテスト | |
| ユーザー |
toof
|
| 提出日時 | 2019-08-09 22:12:23 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,023 bytes |
| 記録 | |
| コンパイル時間 | 1,181 ms |
| コンパイル使用メモリ | 211,304 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-07 16:26:38 |
| 合計ジャッジ時間 | 2,015 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 4 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:38:20: warning: 'm' may be used uninitialized [-Wmaybe-uninitialized]
38 | cmin(ans, s+d[m]+d[gg]-g);
| ^
main.cpp:36:9: note: 'm' was declared here
36 | int m;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }
int main() {
cin.tie(0); ios::sync_with_stdio(false);
vector<int> d(3);
rep(i, 3) {
cin >> d[i];
}
char a, b;
int s, g;
cin >> a >> s >> b >> g;
int ss = a-'A';
int gg = b-'A';
ll ans = 1e10;
if (ss == gg) {
cmin(ans, abs(s-g));
ll m = 1e10;
rep(i, 3) {
if (i != ss) cmin(m, d[i]);
}
cmin(ans, min(s, g) + d[ss] - max(s, g) + m);
} else {
cmin(ans, s+g-1);
cmin(ans, d[ss]-s+d[ss]-g+1);
int m;
rep(i, 3) if (i != ss && i != gg) m = i;
cmin(ans, s+d[m]+d[gg]-g);
cmin(ans, d[ss]-s+d[m]+g);
}
cout << ans << endl;
}
toof