結果

問題 No.1898 Battle and Exchange
ユーザー SSRSSSRS
提出日時 2022-04-08 22:35:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,497 bytes
コンパイル時間 2,371 ms
コンパイル使用メモリ 214,092 KB
実行使用メモリ 11,452 KB
最終ジャッジ日時 2023-08-19 01:02:01
合計ジャッジ時間 25,040 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 52 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 27 ms
4,380 KB
testcase_18 AC 123 ms
4,664 KB
testcase_19 AC 202 ms
5,356 KB
testcase_20 AC 230 ms
5,604 KB
testcase_21 AC 573 ms
9,036 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 33 ms
4,380 KB
testcase_28 AC 44 ms
4,380 KB
testcase_29 AC 141 ms
4,376 KB
testcase_30 AC 11 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 122 ms
5,240 KB
testcase_33 WA -
testcase_34 AC 94 ms
4,992 KB
testcase_35 AC 161 ms
5,976 KB
testcase_36 AC 97 ms
5,768 KB
testcase_37 AC 65 ms
4,380 KB
testcase_38 AC 705 ms
11,452 KB
testcase_39 AC 546 ms
9,616 KB
testcase_40 AC 601 ms
10,312 KB
testcase_41 AC 478 ms
9,456 KB
testcase_42 AC 21 ms
4,376 KB
testcase_43 AC 397 ms
7,740 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 40 ms
4,380 KB
testcase_46 AC 187 ms
5,360 KB
testcase_47 AC 41 ms
4,376 KB
testcase_48 AC 94 ms
4,380 KB
testcase_49 AC 27 ms
4,376 KB
testcase_50 AC 27 ms
4,376 KB
testcase_51 AC 26 ms
4,376 KB
testcase_52 AC 59 ms
4,376 KB
testcase_53 AC 273 ms
4,900 KB
testcase_54 AC 402 ms
5,232 KB
testcase_55 AC 319 ms
5,032 KB
testcase_56 AC 404 ms
5,364 KB
testcase_57 WA -
testcase_58 AC 645 ms
9,764 KB
testcase_59 AC 648 ms
9,832 KB
testcase_60 AC 640 ms
9,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF = 300000000;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int U, V;
    cin >> U >> V;
    U--;
    V--;
    E[U].push_back(V);
    E[V].push_back(U);
  }
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i] >> C[i];
  }
  int mn = INF;
  for (int v : E[0]){
    mn = min(mn, A[v] + B[v] + C[v]);
  }
  int tv = 300000000, fv = A[0] + B[0] + C[0] - 2;
  while (tv - fv > 1){
    int mid = (tv + fv) / 2;
    int a = mid, b = 1, c = 1;
    if (mid - 1 + max({A[0], B[0], C[0]}) < mn){
      fv = mid;
    } else {
      vector<bool> used(N, false);
      priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
      pq.push(make_pair(A[0] + B[0] + C[0], 0));
      while (!pq.empty()){
        int sum = pq.top().first;
        int v = pq.top().second;
        pq.pop();
        if (!used[v] && sum < a + b + c){
          used[v] = true;
          vector<int> tmp = {a, b, c, A[v], B[v], C[v]};
          sort(tmp.begin(), tmp.end(), greater<int>());
          a = tmp[0];
          b = tmp[1];
          c = tmp[2];
          for (int w : E[v]){
            if (!used[w]){
              pq.push(make_pair(A[w] + B[w] + C[w], w));
            }
          }
        }
      }
      if (used[N - 1]){
        tv = mid;
      } else {
        fv = mid;
      }
    }
  }
  cout << tv << ' ' << 1 << ' ' << 1 << endl;
}
0