結果

問題 No.859 路線A、路線B、路線C
ユーザー CleyLCleyL
提出日時 2019-08-09 22:23:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,079 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 65,612 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 18:24:29
合計ジャッジ時間 1,253 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
#define x34 min(a2,b2)
#define y34 max(a2,b2)
int main(){
  long long a,b,c;cin>>a>>b>>c;a++;b++;c++;
  char a1;long long a2;cin>>a1>>a2;
  char b1;long long b2;cin>>b1>>b2;
  if(a1==b1){
    if(a1=='A')cout << min(y34-x34,x34+(a-y34)-2+(min(c,b)));
    if(a1=='B')cout << min(y34-x34,x34+(b-y34)-2+(min(a,c)));
    if(a1=='C')cout << min(y34-x34,x34+(c-y34)-2+(min(a,b)));
  }else{
    if(a1=='A'){
      if(b1=='B') cout << min(min(a2+b2-1,(a-a2)+(b-b2)-1),min(c-1+a2+(b-b2),c-1+b2+(a-a2))-1);
      else        cout << min(min(a2+b2-1,(a-a2)+(c-b2)-1),min(b-1+a2+(c-b2),b-1+b2+(a-a2))-1);
    }else if(a1=='B'){
      if(b1=='A') cout << min(min(a2+b2-1,(b-a2)+(a-b2)-1),min(c-1+a2+(a-b2),c-1+b2+(b-a2))-1);
      else        cout << min(min(a2+b2-1,(b-a2)+(c-b2)-1),min(a-1+a2+(c-b2),a-1+b2+(b-a2))-1);
    }else{
      if(b1=='A') cout << min(min(a2+b2-1,(c-a2)+(a-b2)-1),min(b-1+a2+(a-b2),b-1+b2+(c-a2))-1);
      else        cout << min(min(a2+b2-1,(c-a2)+(b-b2)-1),min(a-1+a2+(b-b2),a-1+b2+(c-a2))-1);
    }
  }
  cout << endl;
}
0