結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-16 10:13:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,017 bytes |
| コンパイル時間 | 1,456 ms |
| コンパイル使用メモリ | 167,672 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 23:16:38 |
| 合計ジャッジ時間 | 2,019 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, z;
cin>>x>>y>>z;
char s0, s1;
long t0, t1;
cin>>s0>>t0;
cin>>s1>>t1;
if (s0 > s1) {
swap(s0, s1);
swap(t0, t1);
} else if (s0 == s1) {
if (t0 > t1) {
swap(t0, t1);
}
}
long ans = x + y + z;
if (s0 == 'A') {
if (s1 == 'A') {
ans = min(t1 - t0, t0 + y + x - t1);
ans = min(t0 + z + x - t1, ans);
} else if (s1 == 'B') {
ans = min(t0 + t1 - 1, x - t0 + y - t1 + 1);
ans = min(t0 + z + y - t1, ans);
} else {
ans = min(t0 + t1 - 1, x - t0 + z - t1 + 1);
ans = min(t0 + y + z - t1, ans);
}
} else if (s0 == 'B') {
if (s1 == 'B') {
ans = min(t1 - t0, t0 + x + y - t1);
ans = min(t0 + z + y - t1, ans);
} else if (s1 == 'C') {
ans = min(t0 + t1 - 1, y - t0 + z - t1 + 1);
ans = min(t0 + x + z - t1, ans);
}
} else {
ans = min(t1 - t0, t0 + x + z - t1);
ans = min(t0 + y + z - t1, ans);
}
cout<<ans<<endl;
}