Submission #1281096

#TimeUsernameProblemLanguageResultExecution timeMemory
1281096sitingfake악어의 지하 도시 (IOI11_crocodile)C++20
0 / 100
1 ms1080 KiB
#include<bits/stdc++.h> using namespace std; // define #define execute cerr << " Time: " << fixed << setprecision(6) << (1.0 * clock() / CLOCKS_PER_SEC) << "s\n"; #define ll long long #define ii pair <int , int> #define iii pair <int , ii> #define se second #define fi first #define all(v) (v).begin() , (v).end() #define Unique(v) sort(all(v)) , v.resize(unique(all(v)) - v.begin()) #define bit(x,i) (((x) >> (i)) & 1LL) #define flip(x,i) ((x) ^ (1LL << (i))) #define ms(d,x) memset(d , x , sizeof(d)) #define exist __exist #define ends __ends #define visit visited #define left __left #define right __right #define sitingfake 1 #define orz 1 //constant const long long mod = 1e9 + 7; const long long linf = 4557430888798830399LL; const long long nlinf = -4485090715960753727LL; const int inf = 1061109567; const int ninf = -1044266559; const int dx[] = {0 , -1 , 0 , 1}; const int dy[] = {-1 , 0 , 1 , 0}; template<typename T> bool maximize(T &a, const T &b) { if(a < b) {a = b; return 1;} return 0; } template<typename T> bool minimize(T &a, const T &b) { if(a > b) {a = b; return 1;} return 0; } void Plus(ll & a ,ll b) { b %= mod; a += b; if(a < 0) a += mod; a %= mod; return; } void Mul(ll & a, ll b) { (a *= (b % mod)) %= mod; return; } //code const int maxn = 1e5 + 7; int n , m , k; ll distS[maxn]; vector <ii> a[maxn]; int p[maxn]; void Dijkstra() { ms(distS , 0x3f); priority_queue <ii , vector <ii> , greater <ii>> pq; for(int i = 1; i <= k; i++) { distS[p[i]] = 0; pq.push({0 , p[i]}); } while(!pq.empty()) { int u = pq.top().se; ll cost = pq.top().fi; pq.pop(); if(cost > distS[u]) continue; for(ii i : a[u]) { int v = i.fi; int w = i.se; if(minimize(distS[v] , distS[u] + w)) { pq.push({distS[v] , v}); } } } } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { n = N , m = M , k = K; for(int i = 1; i <= m; i++) { int u = R[i][0] , v = R[i][1] , w = L[i]; a[u].push_back({v , w}); a[v].push_back({u , w}); } for(int i = 1; i <= k; i++) { p[i] = P[i]; } Dijkstra(); vector <ll> dist(n + 2 , linf); dist[0] = 0; priority_queue <iii , vector <iii> , greater <iii>> pq; pq.push({0 , {0 , -1}}); while(!pq.empty()) { int u = pq.top().se.fi; int pre = pq.top().se.se; ll cost = pq.top().fi; pq.pop(); if(cost > dist[u]) continue; ii mi = {inf , inf}; int banned = 0; for(ii it : a[u]) { int v = it.fi; int w = it.se; if(v == pre) continue; if(minimize(mi , {distS[v] , w})) { banned = v; } } for(ii it : a[u]) { int v = it.fi; int w = it.se; if(v == pre || v == banned) continue; if(minimize(dist[v] , dist[u] + w)) { pq.push({dist[v] , {v , u}}); } } } ll ans = linf; for(int i = 1; i <= k; i++) { minimize(ans , dist[p[i]]); } return (int)ans; } //void solve(void) //{ // int n , m , k; // int r[maxn][2] , l[maxn] , p[maxn]; // cin >> n >> m >> k; // for(int i = 1; i <= m; i++) // { // cin >> r[i][0] >> r[i][1]; // } // for(int i = 1; i <= m; i++) // { // cin >> l[i]; // } // for(int i = 1; i <= k; i++) // { // cin >> p[i]; // } // cout << travel_plan(n , m , r , l , k , p); //} ///** //5 7 2 //0 2 //0 3 //3 2 //2 1 //0 1 //0 4 //3 4 //4 3 2 10 100 7 9 //1 3 // //5 4 3 //0 1 //0 2 //3 2 //2 4 //2 3 1 4 //1 3 4 //**/ //signed main() //{ // ios_base::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); // // #define task "" // // if(fopen(task".inp","r")) // { // freopen(task".inp","r",stdin); // freopen(task".out","w",stdout); // } // // int tc = 1; //// cin >> tc; // while(tc--) solve(); // //// execute; //}

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:142:24: warning: narrowing conversion of 'dist.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)v))' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
  142 |                 pq.push({dist[v] , {v , u}});
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...