제출 #1268614

#제출 시각아이디문제언어결과실행 시간메모리
1268614duyanhloveavConstruction Project 2 (JOI24_ho_t2)C++20
0 / 100
9 ms684 KiB
#include <bits/stdc++.h>
using namespace std;

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1LL)

using ll = long long;

const int mxn = 9 + 1e6;
const int inf = 0x3f3f3f3f;
const ll lnf = 0x3f3f3f3f3f3f3f3f;

#define int long long

void _27augain(void) {
  int n, m;
  cin >> n >> m;
  int s, t, l, k;
  cin >> s >> t >> l >> k;
  --s, --t;
  vector<vector<array<int, 2>>> adj(n);
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  auto dijkstra = [&] (int x) -> vector<int> {
    vector<int> d(n, lnf);
    priority_queue<array<int, 2>> pq;
    pq.push({d[x] = 0, x});
    while (!pq.empty()) {
      int w = -pq.top()[0], u = pq.top()[1];
      pq.pop();
      if (w > d[u]) {
        continue;
      }
      for (auto &y : adj[u]) {
        if (d[y[0]] > d[u] + y[1]) {
          d[y[0]] = d[u] + y[1];
          pq.push({-d[y[0]], y[0]});
        }
      }
    }
    return d;
  };
  vector<int> dS = dijkstra(s), dT = dijkstra(t);
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i ^ j && dS[i] ^ lnf && dT[j] ^ lnf && dS[i] + dT[j] <= k - l) {
        ++res;
      }
    }
  }
  cout << res << "\n";
}

int32_t main(void) {
#define task "_27augain"
  cin.tie(0)->sync_with_stdio(0);
  for (string iext : {"in", "inp"}) {
    if (fopen((task "." + iext).c_str(), "r")) {
      freopen((task "." + iext).c_str(), "r", stdin);
      freopen(task ".out", "w", stdout);
    }
  }
  int testcase = 1;
  // cin >> testcase;
  while (testcase--) {
    _27augain();
  }
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int32_t main()':
Main.cpp:65:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |       freopen((task "." + iext).c_str(), "r", stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |       freopen(task ".out", "w", stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...