結果
問題 |
No.859 路線A、路線B、路線C
|
ユーザー |
![]() |
提出日時 | 2019-08-09 22:12:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,023 bytes |
コンパイル時間 | 1,807 ms |
コンパイル使用メモリ | 194,968 KB |
最終ジャッジ日時 | 2025-01-07 11:23:06 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 4 |
ソースコード
#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; }