제출 #814463

#제출 시각아이디문제언어결과실행 시간메모리
814463Hanksburger사이버랜드 (APIO23_cyberland)C++17
44 / 100
34 ms12840 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; long long dist[100005], final[100005], ok[100005], h; vector<pair<long long, long long> > adj[100005]; priority_queue<pair<long long, long long> > pq; void dfs(long long u) { ok[u]=1; for (long long i=0; i<adj[u].size(); i++) { long long v=adj[u][i].first; if (ok[v] || v==h) continue; dfs(v); } } double solve(int n, int m, int k, int hh, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { h=hh; for (long long i=0; i<n; i++) adj[i].clear(); for (long long i=0; i<m; i++) { adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } for (long long i=0; i<n; i++) ok[i]=0; dfs(0); for (long long i=0; i<n; i++) { dist[i]=1e18; final[i]=0; } dist[0]=0; pq.push({0, 0}); for (long long i=1; i<n; i++) { if (!a[i] && ok[i]) { dist[i]=0; pq.push({0, i}); } } while (!pq.empty()) { long long u=pq.top().second; pq.pop(); if (final[u]) continue; final[u]=1; for (long long i=0; i<adj[u].size(); i++) { long long v=adj[u][i].first, w=adj[u][i].second; if (dist[u]+w<dist[v]) { dist[v]=dist[u]+w; pq.push({-dist[v], v}); } } } if (dist[h]<5e17) return dist[h]; else return -1; }

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

cyberland.cpp: In function 'void dfs(long long int)':
cyberland.cpp:10:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (long long i=0; i<adj[u].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:53:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for (long long i=0; i<adj[u].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...