제출 #784007

#제출 시각아이디문제언어결과실행 시간메모리
784007ZHIRDILBILDIZ사이버랜드 (APIO23_cyberland)C++17
44 / 100
444 ms10060 KiB
#include<bits/stdc++.h> #include "cyberland.h" #define ll long long #define fi first #define se second using namespace std ; const int N = 1e5 ; bool us[N] ; double dist[N] ; vector<pair<int, int>> v[N] ; set<pair<double, int>> s ; void deikstra() { for(int i = 0 ; i < N ; i++) dist[i] = 1e18 ; for(auto i : s) dist[i.se] = 0 ; while(s.size()) { pair<double, int> p = *s.begin() ; s.erase(s.begin()) ; if(us[p.se]) continue ; us[p.se] = 1 ; for(auto i : v[p.se]) { if(us[i.fi] || dist[i.fi] <= p.fi + i.se) continue ; dist[i.fi] = p.fi + i.se ; s.insert({dist[i.fi], i.fi}) ; } } } double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { bool flag1 = 0, flag2 = 0 ; s.clear() ; for(int i = 0 ; i < n ; i++) { us[i] = 0 ; dist[i] = 0 ; v[i].clear() ; if(arr[i] != 1)flag1 = 1 ; if(arr[i] == 2)flag2 = 1 ; } for(int i = 0 ; i < m ; i++) { v[x[i]].push_back({y[i], c[i]}) ; v[y[i]].push_back({x[i], c[i]}) ; } if(!flag1) { s.insert({0, 0}) ; deikstra() ; if(dist[h] == 1e18) return -1 ; else return dist[h] ; } if(!flag2) { us[h] = 1 ; s.insert({0, 0}) ; deikstra() ; for(int i = 0 ; i < n ; i++) { if(us[i] && !arr[i] || !i) s.insert({0, i}) ; us[i] = 0 ; } deikstra() ; if(dist[h] == 1e18) return -1 ; else return dist[h] ; } } //signed main() //{ // ios_base::sync_with_stdio( 0 ) ; // cin.tie( 0 ) ; // cout.tie( 0 ) ; // int t ; // cin >> t ; // while(t--) // { // int n, m, k, h ; // cin >> n >> m >> k >> h ; // vector<int> a(m), b(m), c(m), arr(n) ; // for(int i = 0 ; i < n ; i++) // cin >> arr[i] ; // for(int i = 0 ; i < m ; i++) // cin >> a[i] >> b[i] >> c[i] ; // cout << fixed << setprecision(9) << solve(n, m, k, h, a, b, c, arr) << '\n' ; // } // return 0 ; //} //1 //13 12 30 //12 //1 1 0 1 1 0 0 0 0 0 1 1 1 //1 0 612949774 //2 0 918186410 //3 0 549451784 //4 3 52491453 //5 3 39361617 //6 5 762672334 //7 1 690365436 //8 0 781197787 //9 0 730324427 //10 6 722788760 //11 6 974046930 //12 5 991661776

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

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:67:22: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   67 |             if(us[i] && !arr[i] || !i)
cyberland.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^
#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...