제출 #1179218

#제출 시각아이디문제언어결과실행 시간메모리
1179218JelalTkm사이버랜드 (APIO23_cyberland)C++20
8 / 100
22 ms5688 KiB
#include <bits/stdc++.h> #include "cyberland.h" #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; // #define int long long int // const int N = 2e5 + 10; // const int md = 1e9 + 7; // const int INF = 1e18; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> w, vector<int> a) { vector<vector<pair<int, int>>> g(n + 1, vector<pair<int, int>> ()); for (int i = 0; i < m; i++) { g[x[i]].push_back({y[i], w[i]}); g[y[i]].push_back({x[i], w[i]}); } vector<double> dist(g.size() + 10, 0); vector<bool> visited(g.size() + 10); set<pair<double, int>> q; dist[h] = 0; q.insert({0, h}); double ans = 0; while (!q.empty()) { int v = (*q.begin()).second; if (a[v] == 0) { ans = dist[v]; break; } q.erase(q.begin()); if (!visited[v]) for (auto i : g[v]) { if (!dist[i.first]) dist[i.first] = dist[v] + (double)i.second; else dist[i.first] = min(dist[i.first], dist[v] + (double)i.second); if (!visited[i.first]) q.insert({dist[i.first], i.first}); } visited[v] = 1; } if (ans != 0) return ans; else return dist[0]; } // int32_t main(int32_t argc, char *argv[]) { // ios::sync_with_stdio(false); // cin.tie(nullptr); // int T = 1; // // cin >> T; // while (T--) { // cout << solve(4, 4, 30, 3, {0, 0, 1, 2}, {1, 2, 3, 3}, {5, 4, 2, 4}, {1, 0, 1, 1}) << '\n'; // } // return 0; // }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...