結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
totori_nyaa
|
| 提出日時 | 2019-08-09 22:03:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,407 bytes |
| コンパイル時間 | 1,604 ms |
| コンパイル使用メモリ | 167,244 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 12:05:42 |
| 合計ジャッジ時間 | 2,087 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
//cout << setprecision(12) ;
ios::sync_with_stdio(false);
cin.tie(0);
ll x,y,z;
cin>>x>>y>>z;
string s1,s2; ll t1,t2;
cin>>s1>>t1>>s2>>t2;
ll ans = 1e18;
if(s1==s2){
if(s1=="B") swap(x,y);
if(s1=="C") swap(z,x);
ans = abs(t2-t1);
ll d1 = t1 + min(y,z) + x-t2;
ll d2 = x-t1 +1 + min(y,z) + t2-1;
ans = min(ans,min(d1,d2));
cout<<ans<<endl;
}
else {
ll a,b,c;
if(s1=="A"){
a=x;
if(s2=="B"){
b=y;
c=z;
}
else {
b=z,c=y;
}
}
else if(s1=="B"){
a=y;
if(s2=="A"){
b=x;
c=z;
}
else {
b=z;
c=x;
}
}
else {
a=z;
if(s2=="A"){
b=x;
c=y;
}
else {
b=y;
c=x;
}
}
ll d1 = t1 + t2-1;
ll d2 = t1 + c + b - t2;
ll d3 = a - t1 + b-t2+1;
ll d4 = a-t1 + c + t2;
//cerr<<d1<<" "<<d2<<" "<<d3<<" "<<d4<<endl;
ans = min(min(d1,d2),min(d3,d4));
cout<<ans<<endl;
}
}
totori_nyaa