제출 #1154291

#제출 시각아이디문제언어결과실행 시간메모리
1154291tsengangConstruction Project 2 (JOI24_ho_t2)C++20
8 / 100
276 ms30164 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define pb push_back #define ertunt return int main() { ll n, m; cin >> n >> m; ll s, t, l, k; cin >> s >> t >> l >> k; vector<vector<pair<ll, ll>>> v(n + 1); for (ll i = 0; i < m; i++) { ll a, b, w; cin >> a >> b >> w; v[a].pb({b, w}); v[b].pb({a, w}); } vector<ll> distt(n + 1, 1e19), dists(n + 1, 1e19); dists[s] = 0; distt[t] = 0; set<pair<ll, ll>> pq; pq.insert({0, s}); while (!pq.empty()) { auto p = *pq.begin(); pq.erase(pq.begin()); for (auto [x, y] : v[p.ss]) { if (dists[x] > dists[p.ss] + y) { pq.erase({dists[x], x}); dists[x] = dists[p.ss] + y; pq.insert({dists[x], x}); } } } pq.insert({0, t}); while (!pq.empty()) { auto p = *pq.begin(); pq.erase(pq.begin()); for (auto [x, y] : v[p.ss]) { if (distt[x] > distt[p.ss] + y) { pq.erase({distt[x], x}); distt[x] = distt[p.ss] + y; pq.insert({distt[x], x}); } } } if (distt[s] <= k) { cout << n * (n - 1) / 2; ertunt 0; } ll ans = 0; vector<ll>L,R; for(ll i = 1; i <= n; i++){ L.pb(dists[i]); R.pb(distt[i]); } sort(all(L)); sort(all(R)); for(ll i = 1; i <= n; i++){ ll nm = upper_bound(all(R),k-l-L[i-1])- R.begin(); ans+=nm; } cout << ans << '\n'; }

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

Main.cpp: In function 'int main()':
Main.cpp:21:29: warning: overflow in conversion from 'double' to 'std::vector<long long int>::value_type' {aka 'long long int'} changes value from '1.0e+19' to '9223372036854775807' [-Woverflow]
   21 |     vector<ll> distt(n + 1, 1e19), dists(n + 1, 1e19);
      |                             ^~~~
Main.cpp:21:49: warning: overflow in conversion from 'double' to 'std::vector<long long int>::value_type' {aka 'long long int'} changes value from '1.0e+19' to '9223372036854775807' [-Woverflow]
   21 |     vector<ll> distt(n + 1, 1e19), dists(n + 1, 1e19);
      |                                                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...