結果

問題 No.859 路線A、路線B、路線C
ユーザー leaf_1415leaf_1415
提出日時 2019-08-09 21:56:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 51,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 17:51:08
合計ジャッジ時間 1,190 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#define llint long long

using namespace std;

llint x, y, z;
char Sc, Tc;
llint Sid, Tid;

int main(void)
{
	cin >> x >> y >> z;
	cin >> Sc >> Sid;
	cin >> Tc >> Tid;
	
	if(Sc == Tc){
		if(Sid > Tid) swap(Sid, Tid);
		if(Sc == 'C') swap(x, z);
		if(Sc == 'B'){
			cout << min(Tid-Sid, Sid+(y-Tid)+min(x, z)) << endl;
			return 0;
		}
		cout << min(Tid-Sid, Sid+(x-Tid)+min(y, z)) << endl;
		return 0;
	}
	else{
		if(Sc == 'B'){
			swap(Sc, Tc);
			swap(Sid, Tid);
		}
		if(Sc == 'C'){
			swap(x, z);
			swap(Sid, Tid);
		}
		
		if(Tc == 'B'){
			llint ans = min(Sid+Tid-1, (x-Sid)+(y-Tid)+1);
			ans = min(ans, min((x-Sid)+z+Tid, Sid+z+(y-Tid)));
			cout << ans << endl;
			return 0;
		}
		cout << min(Sid+Tid-1, min(Sid+y+(z-Tid), (x-Sid)+(z-Tid)+1)) << endl;
		
	}
	
	return 0;
}
0