結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-08 23:36:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,228 bytes |
| コンパイル時間 | 1,509 ms |
| コンパイル使用メモリ | 167,580 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 05:53:28 |
| 合計ジャッジ時間 | 2,213 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 1 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:39:13: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
39 | cout << ans << endl;
| ^~~
main.cpp:15:9: note: 'ans' was declared here
15 | int ans;
| ^~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pp = pair<bool,bool>;
const int INF = 1e9;
const int MOD = 1000000007;
int main(){
int x,y,z;
cin >> x >> y >> z;
char S,T;
int s,t;
int ans;
cin >> S >> s >> T >> t;
if(S == 'A' && T =='B'){
ans = min({s+t-1,x-s+y-t+1,t+z+x-s,s+z+y-t});
}else if(S == 'B' && T == 'A'){
ans = min({s+t-1,x-t+y-s+1,s+z+x-t,t+z+y-s});
}else if(S == 'B' && T == 'C'){
ans = min({s+t-1,y-s+z-t+1,s+x+z-t,y-s+x+t});
}else if(S == 'C' && T == 'B'){
ans = min({s+t-1,y-t+z-s+1,t+x+z-s,y-t+x+s});
}else if(S == 'A' && T == 'C'){
ans = min({s+t-1,x-s+z-t+1,s+y+z-t,x-s+y+t});
}else if(S =='C' && T == 'A'){
ans = min({s+t-1,x-t+z-s+1,t+y+z-s,x-t+y+s});
}else if(S == 'C' && T =='C'){
if(s > t) swap(s,t);
ans = min({t-s,s+z-t+x,s+z-t+y});
}else if(S == 'B' && T =='B'){
if(s > t) swap(s,t);
ans = min({t-s,s+y-t+x,s+y-t+z});
}else if(S == 'A' && T =='A'){
if(s > t) swap(s,t);
ans = min({t-s,s+x-t+y,s+x-t+z});
}
cout << ans << endl;
return 0;
}