Submission #756121

#TimeUsernameProblemLanguageResultExecution timeMemory
756121yellowtoadCyberland (APIO23_cyberland)C++17
100 / 100
1646 ms127124 KiB
#include "cyberland.h" #include <iostream> #include <vector> #include <queue> #define f first #define s second using namespace std; long long n, m, k, h, arr[100010]; long double dist[75][100010], minn; bool vis[100010]; vector<pair<int,long long>> edge[100010]; priority_queue<pair<long double,int>,vector<pair<long double,int>>,greater<pair<long double,int>>> pq; void dfs(int u) { if (arr[u] == 0) dist[0][u] = 0; vis[u] = 1; for (int i = 0; i < edge[u].size(); i++) if (!vis[edge[u][i].f]) dfs(edge[u][i].f); } double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> ARR) { n = N; m = M; k = min(K,70); h = H; minn = 1e18; for (int i = 0; i < n; i++) arr[i] = ARR[i]; for (int i = 0; i < n; i++) edge[i].clear(); for (int i = 0; i < m; i++) { edge[x[i]].push_back({y[i],c[i]}); edge[y[i]].push_back({x[i],c[i]}); } for (int i = 0; i <= k; i++) for (int j = 0; j < n; j++) dist[i][j] = 1e18; for (int i = 0; i < n; i++) vis[i] = 0; vis[h] = 1; dfs(0); dist[0][0] = 0; for (int i = 0; i <= k; i++) { for (int j = 0; j < n; j++) if (dist[i][j] != 1e18) pq.push({dist[i][j],j}); for (int i = 0; i < n; i++) vis[i] = 0; vis[h] = 1; while (pq.size()) { int u = pq.top().s; pq.pop(); if (vis[u]) continue; vis[u] = 1; for (int j = 0; j < edge[u].size(); j++) { if (dist[i][u]+edge[u][j].s < dist[i][edge[u][j].f]) { dist[i][edge[u][j].f] = dist[i][u]+edge[u][j].s; pq.push({dist[i][edge[u][j].f],edge[u][j].f}); } if (arr[edge[u][j].f] == 2) dist[i+1][edge[u][j].f] = min(dist[i+1][edge[u][j].f],(dist[i][u]+edge[u][j].s)/2); } } } for (int i = 0; i <= k; i++) minn = min(minn,dist[i][h]); if (minn == 1e18) return -1; else return minn; }

Compilation message (stderr)

cyberland.cpp: In function 'void dfs(int)':
cyberland.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < edge[u].size(); i++) if (!vis[edge[u][i].f]) dfs(edge[u][i].f);
      |                     ~~^~~~~~~~~~~~~~~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:43:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             for (int j = 0; j < edge[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...