結果

問題 No.859 路線A、路線B、路線C
ユーザー shop_oneshop_one
提出日時 2019-08-09 22:02:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 65,388 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-26 18:06:56
合計ジャッジ時間 1,309 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,384 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long ll;
int no(int a,int b){
  if((a==0&&b==1)||(a==1&&b==0))return 2;
  if((a==0&&b==2)||(a==2&&b==0))return 1;
  return 0;
}
int main(){
  ll xyz[3],t0,i,t1,ml=100000000000000,n0,n1,outl,gf,ge;
  char s0,s1;
  cin >> xyz[0] >> xyz[1] >> xyz[2] >> s0>>t0>>s1>>t1;
  n0=s0-'A';
  n1=s1-'A';
  if(n0==n1){
    outl = min(t0,xyz[n0]-t0)+min(t1,xyz[n1]-t1)-2;
    ml = min(abs(t1-t0),outl+min(xyz[(n0+1)%3],xyz[(n0+2)%3]));
  }else{
    i = no(n0,n1);
    gf = min(t0-1,xyz[n0]-t0+xyz[i]);
    ge = min(xyz[n0]-t0-1,t0+xyz[i]);
    ml = min(gf+t1,ge+xyz[n1]-t1);
  }
  cout << ml<<endl;
}
0