Submission #978145

#TimeUsernameProblemLanguageResultExecution timeMemory
978145math_rabbit_1028Cyberland (APIO23_cyberland)C++17
0 / 100
261 ms13276 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int n, m, k, h; vector<pll> adj[101010]; int ch[101010]; void DFS(int v) { if (ch[v]) return; ch[v] = 1; for (int i = 0; i < adj[v].size(); i++) { int u = adj[v][i].first; DFS(u); } } ll dis[101010]; priority_queue<pll> pq; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { n = N; m = M; k = K; h = H; 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]}); } for (int i = 0; i < n; i++) ch[i] = 0; DFS(0); dis[0] = 0; pq.push({-dis[0], 0}); for (int i = 0; i < n; i++) { if (arr[i] == 0 && ch[i] == 1) { dis[i] = 0; pq.push({-dis[i], i}); } else { dis[i] = 1e18; } } while (!pq.empty()) { int v = pq.top().second; ll w = -pq.top().first; pq.pop(); if (dis[v] < w) continue; for (int i = 0; i < adj[v].size(); i++) { int u = adj[v][i].first; ll ww = adj[v][i].second; if (dis[u] > w + ww) { dis[u] = w + ww; pq.push({-dis[u], u}); } } } if (dis[h] >= 1e18) return -1; else return dis[h]; }

Compilation message (stderr)

cyberland.cpp: In function 'void DFS(int)':
cyberland.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i = 0; i < adj[v].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for (int i = 0; i < adj[v].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~
#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...