Submission #822677

#TimeUsernameProblemLanguageResultExecution timeMemory
822677HanksburgerCyberland (APIO23_cyberland)C++17
44 / 100
300 ms28752 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; priority_queue<pair<double, int> > pq; vector<pair<int, int> > adj[100005]; int ok[100005], final[100005]; double dist[65][100005]; queue<int> q; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { k=min(k, 60); for (int i=0; i<n; i++) { adj[i].clear(); ok[i]=0; } for (int i=0; i<m; i++) { adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } ok[0]=1; q.push(0); while (!q.empty()) { int u=q.front(); q.pop(); if (u==h) continue; for (int i=0; i<adj[u].size(); i++) { int v=adj[u][i].first; if (!ok[v]) { ok[v]=1; q.push(v); } } } for (int i=0; i<=k; i++) for (int j=0; j<n; j++) dist[i][j]=1e18; dist[0][0]=0; pq.push({0, 0}); for (int i=0; i<=k; i++) { for (int j=0; j<n; j++) { if (ok[j] && !a[j]) { dist[i][j]=0; pq.push({0, j}); } } if (i) { for (int j=0; j<n; j++) { if (ok[j] && a[j]==2) { for (int l=0; l<adj[j].size(); l++) { int v=adj[j][l].first, w=adj[j][l].second; dist[i][v]=min(dist[i][v], dist[i-1][j]/2+w); pq.push({-dist[i][v], v}); } } } } for (int j=0; j<n; j++) final[j]=0; while (!pq.empty()) { int u=pq.top().second; pq.pop(); if (final[u]) continue; final[u]=1; for (int j=0; j<adj[u].size(); j++) { int v=adj[u][j].first, w=adj[u][j].second; if (ok[v] && dist[i][u]+w<dist[i][v]) { dist[i][v]=dist[i][u]+w; pq.push({-dist[i][v], v}); } } } } double mn=1e18; for (int i=0; i<=k; i++) mn=min(mn, dist[i][h]); if (mn<5e17) return mn; else return -1; }

Compilation message (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:30:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int i=0; i<adj[u].size(); i++)
      |                       ~^~~~~~~~~~~~~~
cyberland.cpp:61:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |                     for (int l=0; l<adj[j].size(); l++)
      |                                   ~^~~~~~~~~~~~~~
cyberland.cpp:79:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             for (int j=0; j<adj[u].size(); j++)
      |                           ~^~~~~~~~~~~~~~
#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...