結果

問題 No.859 路線A、路線B、路線C
ユーザー KKT89KKT89
提出日時 2019-08-09 21:44:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 65,104 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 17:37:25
合計ジャッジ時間 1,302 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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+x-t2,min(z-t1+x-t2+1,z-t1+y+t2))) << endl;
	}
}
0