結果
問題 | No.859 路線A、路線B、路線C |
ユーザー | toku |
提出日時 | 2019-08-09 22:10:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,904 bytes |
コンパイル時間 | 1,322 ms |
コンパイル使用メモリ | 161,608 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 12:07:43 |
合計ジャッジ時間 | 1,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:69:58: warning: ‘d’ may be used uninitialized in this function [-Wmaybe-uninitialized] 69 | ll ans = min({ a + b - 1,c + d + 1,x + a + d,x + b + c }); | ~~~~~~^~~ main.cpp:74:44: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized] 74 | ll ans = min({ a + b - 1,c + d + 1,y + a + d,y + b + c }); | ~~^~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i<int(n); i++) #define FOR(i,m,n) for(int i=int(m); i<int(n); i++) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VLL vector<long long> #define VVI vector<vector<int>> #define VVLL vector<vector<long long>> #define VC vector<char> #define VS vector<string> #define VVC vector<vector<char>> #define VB vector<bool> #define VVB vector<vector<bool>> #define fore(i,a) for(auto &i:a) typedef pair <int, int> P; template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1 << 30; const ll INFL = 1LL << 60; const ll mod = 1000000007; int main() { ll x, y, z; cin >> x >> y >> z; char sa, sb; ll ta, tb; cin >> sa >> ta >> sb >> tb; if (sa == sb) { ll ans = abs(tb - ta); if (tb < ta)swap(ta, tb); if (sa == 'A') { ans = min(ans, y + ta - tb + x); ans = min(ans, z + ta - tb + x); } else if (sa == 'B') { ans = min(ans, x + ta - tb + y); ans = min(ans, z + ta - tb + y); } else if (sa == 'C') { ans = min(ans, x + ta - tb + z); ans = min(ans, y + ta - tb + z); } cout << ans << endl; return 0; } ll a, b, c, d; a = ta; b = tb; if (sa == 'A')c = x - ta; if (sa == 'B')c = y - ta; if (sa == 'C')c = z - ta; if (sb == 'A')d = x - tb; if (sb == 'B')d = y - tb; if (sb == 'C')d = z - tb; if (sa != 'A'&&sb != 'A') { ll ans = min({ a + b - 1,c + d + 1,x + a + d,x + b + c }); cout << ans << endl; return 0; } if (sa != 'B'&&sb != 'B') { ll ans = min({ a + b - 1,c + d + 1,y + a + d,y + b + c }); cout << ans << endl; return 0; } if (sa != 'C'&&sb != 'C') { ll ans = min({ a + b - 1,c + d + 1,z + a + d,z + b + c }); cout << ans << endl; return 0; } }