제출 #36204

#제출 시각아이디문제언어결과실행 시간메모리
36204WhipppedCream새로운 문제 (POI13_cen)C++14
0 / 100
129 ms10812 KiB
#include <bits/stdc++.h> //#ifdef atom #else #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vvi vector< vi > #define vii vector< ii > #define mp make_pair #define pb push_back const int maxn = 1e5+5; int n, m, k, a, b; vector<int> adj[maxn]; vector< ii > adj2[maxn]; int dist[maxn]; int len[maxn]; int cost(int x) { return min(2*a, b)*(x/2)+a*(x%2); } int main() { //#ifndef atom //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); //#endif scanf("%d %d %d %d %d", &n, &m, &k, &a, &b); for(int i = 1; i<= n; i++) dist[i] = len[i] = 1e9; for(int i = 1; i<= m; i++) { int a, b; scanf("%d %d", &a, &b); adj[a].pb(b); adj[b].pb(a); } dist[k] = 0; queue<int> Q; Q.push(k); while(!Q.empty()) { int u = Q.front(); Q.pop(); for(auto v : adj[u]) { if(dist[v]>dist[u]+1) { dist[v] = dist[u]+1; Q.push(v); } } } for(int i = 1; i<= n; i++) len[i] = cost(dist[i]); for(int i = 1; i<= n; i++) { if(i == k) continue; for(auto v : adj[i]) { if(v == k) continue; if(dist[i]%2 == dist[v]%2) { len[i] = min(len[i], cost(dist[i]+1)); len[v] = min(len[v], cost(dist[v]+1)); } } } for(int i = 1; i<= n; i++) printf("%d\n", len[i]); }

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

cen.cpp: In function 'int main()':
cen.cpp:29:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d %d", &n, &m, &k, &a, &b);
                                                ^
cen.cpp:33:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int a, b; scanf("%d %d", &a, &b);
                                         ^
#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...