제출 #1063498

#제출 시각아이디문제언어결과실행 시간메모리
1063498EkinOnal새로운 문제 (POI13_cen)C++17
0 / 100
41 ms11220 KiB
//#pragma GCC optimize("O3,unroll-loops,Ofast") //#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; #define MAX 200007 #define pb push_back #define mp make_pair //#define int long long #define f first #define s second #define vi vector<int> #define pii pair<int,int> #define si set<int> #define vpii vector<pair<int,int>> const int mod = 1e9+7; //const int INF = 1e18; // myMap.begin()->first : key // myMap.begin()->second : value int epow(int a,int b){int ans=1;while(b){if(b&1) ans*=a;a*=a;;b>>=1;}return ans;} int gcd(int a,int b) {if(a<b)swap(a,b);while(b){int tmp=b;b=a%b;a=tmp;}return a;} int mul(int a,int b){return ((a%mod)*(b%mod))%mod;} int sum(int a,int b){return ((a%mod)+(b%mod))%mod;} //typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; void solve(){ int n,m,k,a,b; cin>>n>>m>>k>>a>>b; vpii adj[n+5]; for(int i=0;i<m;i++){ int x,y; cin>>x>>y; adj[x].pb({y,a}); adj[y].pb({x,a}); } vi used1(n+5); for(int i=1;i<=n;i++){ queue<pii> q; q.push({i,0}); used1.clear(); while(q.size()){ auto node = q.front(); q.pop(); used1[node.f]=true; // cout<<node.f<<" "<<node.s<<endl; if(node.s==2){ adj[i].pb({node.f,b}); adj[node.f].pb({i,b}); // cout<<i<<" "<<node.f<<endl; continue; } for(auto u : adj[node.f]){ if(u.s==b || used1[u.f]) continue; // ikinci kosuldan emin degilim!! q.push({u.f,node.s+1}); used1[u.f]=true; } } } priority_queue<pii,vector<pii>,greater<pii>> pq; pq.push({0,k}); vi dist(n+5,1e9),used(n+5); dist[k]=0; while(pq.size()){ auto node = pq.top(); pq.pop(); if(dist[node.s]!=node.f) continue; for(auto u : adj[node.s]){ if(dist[u.f]>dist[node.s]+u.s){ dist[u.f]=dist[node.s]+u.s; pq.push({dist[u.f],u.f}); } } } for(int i=1;i<=n;i++) cout<<dist[i]<<"\n";; return; } int32_t main() { // freopen("hayfeast.in", "r", stdin); // freopen("hayfeast.out", "w", stdout); ios_base::sync_with_stdio(0);cin.tie(0); int t=1; // cin >> t; while (t--) solve(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...