結果
問題 | No.859 路線A、路線B、路線C |
ユーザー | KKT89 |
提出日時 | 2019-08-09 21:51:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 11:44:49 |
合計ジャッジ時間 | 1,201 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <iostream> #include <string> using namespace std; typedef long long int ll; int main(){ ll x,y,z; cin >> x >> y >> z; char s1,s2; ll t1,t2; cin >> s1 >> t1 >> s2 >> t2; if(s1==s2&&s1=='A'){ if(t1>t2)swap(t1,t2); cout << min(t1-t2+x+z,min(t1+y+x-t2,t2-t1)) << endl; } if(s1==s2&&s1=='B'){ if(t1>t2)swap(t1,t2); cout << min(t1-t2+y+z,min(t1+y+x-t2,t2-t1)) << endl; } if(s1==s2&&s1=='C'){ if(t1>t2)swap(t1,t2); cout << min(t1-t2+y+z,min(t1+z+x-t2,t2-t1)) << endl; } if(s1>s2){ swap(s1,s2); swap(t1,t2); } if(s1=='A'&&s2=='B'){ cout << min(t1-1+t2,min(t1+z+y-t2,min(x-t1+y-t2+1,x-t1+z+t2))) << endl; } if(s1=='B'&&s2=='C'){ cout << min(t1-1+t2,min(t1+x+z-t2,min(y-t1+z-t2+1,y-t1+x+t2))) << endl; } if(s1=='A'&&s2=='C'){ cout << min(t1-1+t2,min(t1+y+z-t2,min(x-t1+z-t2+1,x-t1+y+t2))) << endl; } }