제출 #978148

#제출 시각아이디문제언어결과실행 시간메모리
978148math_rabbit_1028사이버랜드 (APIO23_cyberland)C++17
44 / 100
33 ms12280 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 (v == h) return; 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 < n; i++) adj[i].clear(); 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 = 1; 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]; }

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

cyberland.cpp: In function 'void DFS(int)':
cyberland.cpp:17: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]
   17 |     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:57: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]
   57 |         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...