제출 #954082

#제출 시각아이디문제언어결과실행 시간메모리
954082Otalp사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define pb push_back #define ff first #define ss second vector<pair<int, int>> q[200100]; double dp[200100][105]; int us[200100][105]; int pos[200100]; int h; void dfs(int v){ pos[v] = 1; if(v == h) return; for(int i=0; i<q[v].size(); i++){ int to = q[v][i].ff; if(pos[to]) continue; dfs(to); } } double st[200]; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { h = h; int k = min(k, 50); for(int i=0; i<n; i++){ q[i].clear(); for(int j=0; j<=k; j++){ dp[i][j] = us[i][j] = 0; } pos[i] = 0; } for(int i=0; i<m; i++){ q[x[i]].pb({y[i], c[i]}); q[y[i]].pb({x[i], c[i]}); } st[0]= 1; for(int i=1; i<=k + 2; i++){ st[i] = st[i - 1] / 2; } dfs(0); if(pos[h] == 0) return -1; set<pair<double, int>> s; s.insert({0, h}); while(s.size()){ auto it = s.begin(); if(us[it -> ss][0]){ s.erase(it); continue; } int v = it -> ss; dp[v][0] = it -> ff; us[v][0] = 1; s.erase(it); for(auto to: q[v]){ if(!us[to.ff][0] and to.ff != h){ s.insert({dp[v][0] + to.ss, to.ff}); } } } for(int c=1; c<=k; c++){ for(int i=0; i<n; i++){ if(pos[i] and arr[i] == 2 and us[i][c-1]){ s.insert({dp[i][c-1], i}); } } while(s.size()){ auto it = s.begin(); if(us[it -> ss][c]){ s.erase(it); continue; } int v = it -> ss; dp[v][c] = it -> ff; us[v][c] = 1; s.erase(it); for(auto to: q[v]){ if(us[to.ff][c] or to.ff == h) continue; s.insert({dp[v][c] + to.ss * st[c], to.ff}); } } } double mn=1e18; if(k < k){ for(int i=0; i<n; i++){ if(us[i][k] and pos[i]) mn = min(mn, dp[i][k]); } } arr[0] = 0; for(int i=0; i<n; i++){ if(pos[i] and arr[i] == 0){ for(int j=0; j<=k; j++){ if(us[i][j]) mn = min(mn, dp[i][j]); } } } if(mn == 1e18) return -1; return mn; }

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

cyberland.cpp: In function 'void dfs(int)':
cyberland.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0; i<q[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:31:9: error: declaration of 'int k' shadows a parameter
   31 |     int k = min(k, 50);
      |         ^
cyberland.cpp:29:32: note: 'int k' previously declared here
   29 | double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
      |                            ~~~~^
cyberland.cpp:96:10: warning: self-comparison always evaluates to false [-Wtautological-compare]
   96 |     if(k < k){
      |        ~ ^ ~