結果
| 問題 | No.859 路線A、路線B、路線C |
| コンテスト | |
| ユーザー |
toku
|
| 提出日時 | 2019-08-09 22:10:00 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,904 bytes |
| 記録 | |
| コンパイル時間 | 884 ms |
| コンパイル使用メモリ | 180,568 KB |
| 実行使用メモリ | 188,536 KB |
| 最終ジャッジ日時 | 2026-04-02 16:37:30 |
| 合計ジャッジ時間 | 1,413 ms |
|
ジャッジサーバーID (参考情報) |
judge4_1 / judge5_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:69:44: warning: 'd' may be used uninitialized [-Wmaybe-uninitialized]
69 | ll ans = min({ a + b - 1,c + d + 1,x + a + d,x + b + c });
| ~~^~~
main.cpp:57:21: note: 'd' was declared here
57 | ll a, b, c, d;
| ^
main.cpp:69:44: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
69 | ll ans = min({ a + b - 1,c + d + 1,x + a + d,x + b + c });
| ~~^~~
main.cpp:57:18: note: 'c' was declared here
57 | ll a, b, c, d;
| ^
ソースコード
#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;
}
}
toku