Submission #919553

#TimeUsernameProblemLanguageResultExecution timeMemory
919553dostsCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("O3,unroll-loops") #include "cyberland.h" #include <bits/stdc++.h> using namespace std; vector<pair<int,int>> edges[100000]; 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) { K = min(K,68); for (int i=0;i<N;i++) edges[i].clear(); for (int i=0;i<M;i++) { edges[x[i]].push_back({y[i],c[i]}); edges[y[i]].push_back({x[i],c[i]}); } int ARR[arr.size()]; for (int i=0;i<arr.size();i++) ARR[i] = arr[i]; double dp[N][K+1]; for (int i=0;i<N;i++) { for (int j=0;j<=K;j++) dp[i][j] = 2e18; } dp[0][0] = 0; for (int used=0;used<=k;used++) { priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> pq; if (used) for (int i=0;i<N;i++) dp[i][used] = dp[i][used-1]; for (int i=0;i<N;i++) pq.push({dp[i][used],i}); while (!pq.empty()) { pair<double,pair<int,int>> f = pq.top(); pq.pop(); double cost = f.first; int city = f.second; if (dp[city][used] < cost) continue; if (city == H) continue; for (auto it : edges[city]) { int dest = it.first; int go = it.second; if (!ARR[dest]) { if (dp[dest][used]>0) { pq.push({0,dest}); dp[dest][used] = 0; } } else { if (dp[dest][used] > cost+go) { pq.push({cost+go,dest}); dp[dest][used] = cost+go; } if (ARR[dest] == 2) { if (dp[dest][used+1] > (cost+go)/2 && used!=K) { pq.push({(cost+go)/2,dest}); dp[dest][used+1] = (cost+go)/2; } } } } } } return dp[H][K]==2e18?-1:dp[H][K]; }

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i=0;i<arr.size();i++) ARR[i] = arr[i];
      |                  ~^~~~~~~~~~~
cyberland.cpp:22:27: error: 'k' was not declared in this scope
   22 |     for (int used=0;used<=k;used++) {
      |                           ^
cyberland.cpp:27:50: error: conversion from 'pair<[...],int>' to non-scalar type 'pair<[...],std::pair<int, int>>' requested
   27 |             pair<double,pair<int,int>> f = pq.top();
      |                                            ~~~~~~^~
cyberland.cpp:30:26: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   30 |             int city = f.second;
      |                        ~~^~~~~~
      |                          |
      |                          std::pair<int, int>