結果
問題 | No.859 路線A、路線B、路線C |
ユーザー |
![]() |
提出日時 | 2023-05-01 17:15:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,053 bytes |
コンパイル時間 | 1,905 ms |
コンパイル使用メモリ | 199,324 KB |
最終ジャッジ日時 | 2025-02-12 16:23:24 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 4 |
ソースコード
#include <bits/stdc++.h>//#include <atcoder/all>using namespace std;//using namespace atcoder;//using mint = modint1000000007;//const int mod = 1000000007;//using mint = modint998244353;//const int mod = 998244353;//const int INF = 1e9;const long long LINF = 1e18;#define rep(i, n) for (int i = 0; i < (n); ++i)#define rep2(i,l,r)for(int i=(l);i<(r);++i)#define rrep(i, n) for (int i = (n-1); i >= 0; --i)#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)#define all(x) (x).begin(),(x).end()#define allR(x) (x).rbegin(),(x).rend()#define endl "\n"#define P pair<int,int>template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }int main() {ios::sync_with_stdio(false);cin.tie(nullptr);long long x, y, z; cin >> x >> y >> z;char s0, s1;int t0, t1;cin >> s0 >> t0; t0--;cin >> s1 >> t1; t1--;vector d(8, vector<long long>(8, LINF));rep(i, 8)d[i][i] = 0;rep(i, 3)rep(j, 3)if (i != j) {d[i][j] = 1;d[i + 3][j + 3] = 1;}d[0][3] = x - 1;d[3][0] = x - 1;d[1][4] = y - 1;d[4][1] = y - 1;d[2][5] = z - 1;d[5][2] = z - 1;if ('A' == s0) {d[0][6] = t0;d[6][0] = t0;d[3][6] = x - 1 - t0;d[6][3] = x - 1 - t0;}else if ('B' == s0) {d[1][6] = t0;d[6][1] = t0;d[4][6] = y - 1 - t0;d[6][4] = y - 1 - t0;}else {d[2][6] = t0;d[6][2] = t0;d[5][6] = z - 1 - t0;d[6][5] = z - 1 - t0;}if ('A' == s1) {d[0][7] = t1;d[7][0] = t1;d[3][7] = x - 1 - t1;d[6][7] = x - 1 - t1;}else if ('B' == s1) {d[1][7] = t1;d[7][1] = t1;d[4][7] = y - 1 - t1;d[7][4] = y - 1 - t1;}else {d[2][7] = t1;d[7][2] = t1;d[5][7] = z - 1 - t1;d[7][5] = z - 1 - t1;}// warshall_floydrep(k, 8) rep(i, 8)rep(j, 8) {d[i][j] = min(d[i][j], d[i][k] + d[k][j]);}long long ans = d[6][7];if (s0 == s1)chmin(ans, abs(t1 - t0));cout << ans << endl;return 0;}