結果

問題 No.614 壊れたキャンパス
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-12-14 21:32:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,567 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 95,260 KB
実行使用メモリ 813,888 KB
最終ジャッジ日時 2024-05-08 10:17:04
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 250 ms
34,756 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 219 ms
25,828 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 MLE -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
using namespace std;
using i64 = long long;

constexpr i64 inf = 987654321987654321LL;
struct edge { int to, cost; };

int main(void) {
  int N, M, K, S, T; scanf("%d%d%d%d%d", &N, &M, &K, &S, &T);
  --S, --T;
  // G[i] := { (i棟の始点の階, i+1棟の終点の階)のリスト }
  vector<vector<pair<int, int>>> G(N);
  vector<vector<int>> cor0(N);
  vector<vector<int>> mat0(N), mat1(N);
  // 始点
  // cor0[a][p] = i 
  // mat0[a][p] = b ... a棟 b階は ノードi a棟で p番目
  // 終点
  // cor1[a+1][p] = i 
  // mat1[a+1][p] = c ... a+1棟 c階は ノードi a+1棟で p番目
  for(int i=0; i<M; ++i) {
    int a, b, c; scanf("%d%d%d", &a, &b, &c);
    --a, --b, --c;
    G[a].emplace_back(b, c);
    cor0[a].push_back(i);
    mat0[a].push_back(b);
    mat1[a+1].push_back(c);
  }
  vector<vector<edge>> H(M+2);
  // a棟 -> a+1棟
  // a棟   b階 -> a+1棟 c階への渡り廊下
  // a+1棟 x階 -> a+2棟 y階への渡り廊下
  for(int a=0; a<N-1; ++a) {
    for(int i=0, n=cor0[a].size(); i<n; ++i) {
      int node0 = cor0[a][i];
      int c     = mat1[a+1][i];
      for(int j=0, m=cor0[a+1].size(); j<m; ++j) {
        int node1 = cor0[a+1][j];
        int x     = mat0[a+1][j];
        H[node0].push_back(edge{node1, abs(c - x)});
      }
    }
  }
  puts("-1");
//  // 0棟 p階 -> 1棟 q階への渡り廊下
//  for(int i=0, n=cor0[0].size(); i<n; ++i) {
//    int node1 = cor0[0][i];
//    int p     = mat0[0][i];
//    H[M].push_back(edge{node1, abs(S - p)});
//  }
//  // N-2棟 b階 -> N-1棟 c階への渡り廊下
//  for(int i=0, n=cor0[N-2].size(); i<n; ++i) {
//    int node0 = cor0[N-2][i];
//    int c     = mat1[N-1][i];
//    H[node0].push_back(edge{M+1, abs(c - T)});
//  }
//
//  // コーナーケース
//  if(N == 1) {
//    H[M].push_back(edge{M+1, abs(S - T)});
//  }
//
//  vector<i64> cost(M+2, inf); // cost[M+2]
//  cost[M] = 0;
//  priority_queue<pair<i64, int>, vector<pair<i64, int>>, greater<pair<i64, int>>> pq;
//  vector<bool> seen(M+2, false); // seen[M+2]
//  // コスト、点番号
//  pq.emplace(0, M);
//  while(!pq.empty()) {
//    i64 _, v; tie(_, v) = pq.top(); pq.pop();
//    if(seen[v]) { continue; }
//    seen[v] = true;
//    for(edge e : H[v]) {
//      if(cost[e.to] > cost[v] + e.cost) {
//        cost[e.to] = cost[v] + e.cost;
//        pq.emplace(cost[e.to], e.to);
//      }
//    }
//  }
//  i64 res = cost[M+1];
//  if(res == inf) { res = -1; }
//  printf("%lld\n", res);
  return 0;
}
0