제출 #1098418

#제출 시각아이디문제언어결과실행 시간메모리
1098418vjudge1Evacuation plan (IZhO18_plan)C++17
100 / 100
348 ms32024 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #define ll int #define F first #define S second #define ull unsigned long long #define db double #define ldb long double #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define yes cout<<"YES\n" #define no cout<<"NO\n" #define all(x) x.begin(), x.end() const int mod = 1e9 + 7; const int N = 1e5 + 7; using namespace std; ll n, m, k, p[N], a, b, c, ans, gv[N], d[N], l, r, used[N], res, mx, pr[N], dep[N], t[N]; vector <ll> st; set <pair <ll, ll>> s; vector <pair <ll, ll>> q, g[N]; ll get (ll a, ll time){ if (a == pr[a] || t[a] < time){ return a; } return get (pr[a], time); } void un (ll a, ll b, ll time){ a = get (a, time); b = get (b, time); if (a == b){ return; } if (dep[a] > dep[b]){ swap (a, b); } pr[a] = b; t[a] = time; dep[b] = max (dep[b], dep[a] + 1); } signed main (){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= m; i++){ cin >> a >> b >> c; g[a].pb({b, c}); g[b].pb ({a, c}); } for (int i = 1; i <= n; i++){ d[i] = 1e9; } cin >> k; for (int i = 1; i <= k; i++){ cin >> p[i]; d[p[i]] = 0; s.insert({0, p[i]}); } while (s.size()){ pair <ll, ll> opa = *s.begin(); s.erase (opa); ll v = opa.second, w = opa.F; for (int i = 0; i < g[v].size(); i++){ if (d[g[v][i].F] > w + g[v][i].S){ s.erase ({d[g[v][i].F], g[v][i].F}); d[g[v][i].F] = w + g[v][i].S; s.insert ({d[g[v][i].F], g[v][i].F}); } } } for (int i = 1; i <= n; i++){ pr[i] = i; dep[i] = 1; q.pb ({d[i], i}); st.pb(d[i]); } sort (all (q)); sort (all (st)); a = q.size() - 1; for (int i = st.size() - 1; i >= 0; i--){ while (a >= 0 && q[a].F >= st[i]){ for (int y = 0; y < g[q[a].S].size(); y++){ if (d[g[q[a].S][y].F] >= st[i])un (q[a].S, g[q[a].S][y].F, st[i]); } a--; } } cin >> k; while (k--){ cin >> a >> b; l = 0, r = st.size() - 1, res = 0; while (l <= r){ ll md = (l + r) / 2; if (get (a, st[md]) == get (b, st[md])){ l = md + 1; res = md; } else{ r = md - 1; } } cout << st[res] << '\n'; } }

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

plan.cpp: In function 'int main()':
plan.cpp:71:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   for (int i = 0; i < g[v].size(); i++){
      |                   ~~^~~~~~~~~~~~~
plan.cpp:90:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |    for (int y = 0; y < g[q[a].S].size(); y++){
      |                    ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...