Submission #1093189

#TimeUsernameProblemLanguageResultExecution timeMemory
1093189serifefedartarPrice List (POI13_cen)C++17
0 / 100
24 ms8540 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0) typedef long long ll; #define f first #define s second #define LOGN 21 const ll MOD = 1e9 + 7; const ll MAXN = 1e5 + 100; vector<vector<int>> graph; int vis[MAXN], dist[MAXN]; int main() { fast; int N, M, K, A, B, u, v; cin >> N >> M >> K >> A >> B; graph = vector<vector<int>>(N+1, vector<int>()); for (int i = 0; i < M; i++) { cin >> u >> v; graph[u].push_back(v); graph[v].push_back(u); } queue<int> q; q.push(K); while (!q.empty()) { int node = q.front(); q.pop(); vis[node] = true; for (auto u : graph[node]) { if (!vis[u]) { dist[u] = dist[node] + 1; vis[u] = true; q.push(u); } } } for (int i = 1; i <= N; i++) cout << min(dist[i] * A, dist[i] / 2 * B + (dist[i] % 2) * A) << "\n"; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...