Submission #1112766

# Submission time Handle Problem Language Result Execution time Memory
1112766 2024-11-14T19:36:09 Z PagodePaiva Cyberland (APIO23_cyberland) C++17
68 / 100
3000 ms 123200 KB
#include<bits/stdc++.h>
#include "cyberland.h"
//#define int long long
#define dp dist
using namespace std;

const int K = 31;
const int N = 100010;

vector <pair <int, int>> g[N];
double dist[N][K][2];
int op[N];

double solve(int32_t n, int32_t m, int32_t k, int32_t h, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> c, std::vector<int32_t> arr) {
    for(int i = 0;i < n;i++){
      g[i].clear();
    }
    for(int i = 0;i < m;i++){
      int a = x[i], b = y[i], w = c[i];
      g[a].push_back({b, w});
      g[b].push_back({a, w});
    }
    for(int i = 0;i < n;i++){
      op[i] = arr[i];
    }
    for(int i = 0;i < n;i++){
      for(int j = 0;j <= k;j++){
        dist[i][j][0] = dist[i][j][1] = 1e18;
      }
    }
    priority_queue <pair <double, array <int, 3>>> pq;
    for(int i = 0;i <= k;i++){
      dist[0][i][0] = 0;
      pq.push({0, {0, i, 0}});
    }
    while(!pq.empty()){
      auto [d,cu] = pq.top();
      auto [v, i, flag] = cu;
      pq.pop();
      d *= -1;
      if(d != dist[v][i][flag]) continue;
      if(v == h) continue;
      if(flag == 0){
        if(op[v] == 0){
          if(dist[v][i][1] > 0){
            dist[v][i][1] = 0;
            pq.push({-dist[v][i][1], {v, i, 1}});
          }
        }
        else if(op[v] == 2){
          if(i > 0){
            if(dist[v][i-1][1] > (dist[v][i][0])/(2.0)){
              dist[v][i-1][1] = (dist[v][i][0])/(2.0);
              pq.push({-dist[v][i-1][1], {v, i-1, 1}});
            }
          }
        }
        else{
          if(dist[v][i][1] > dist[v][i][0]){
            dist[v][i][1] = dist[v][i][0];
            pq.push({-dist[v][i][1], {v, i, 1}});
          }
        }
      }
      for(auto [x, w] : g[v]){
        if(dist[v][i][flag]+w < dist[x][i][0]){
          dist[x][i][0] = dist[v][i][flag]+w;
          pq.push({-dist[x][i][0], {x, i, 0}});
        }
      }
    }
  double res = 1e18;
  for(int i = 0;i <= k;i++){
    res = min(res, dp[h][i][0]);
  }        
  return (res == 1e18 ? -1 : res);
}
# Verdict Execution time Memory Grader output
1 Correct 62 ms 2836 KB Correct.
2 Correct 62 ms 2876 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 357 ms 3748 KB Correct.
2 Correct 435 ms 3724 KB Correct.
3 Correct 438 ms 3732 KB Correct.
4 Correct 433 ms 3716 KB Correct.
5 Correct 443 ms 3748 KB Correct.
6 Correct 420 ms 10540 KB Correct.
7 Correct 534 ms 10304 KB Correct.
8 Correct 239 ms 16832 KB Correct.
9 Correct 365 ms 2932 KB Correct.
10 Correct 355 ms 2896 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 655 ms 3944 KB Correct.
2 Correct 615 ms 4032 KB Correct.
3 Correct 598 ms 4256 KB Correct.
4 Correct 554 ms 3000 KB Correct.
5 Correct 541 ms 2896 KB Correct.
6 Correct 129 ms 10428 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 522 ms 34976 KB Correct.
2 Correct 918 ms 3448 KB Correct.
3 Correct 770 ms 3400 KB Correct.
4 Correct 829 ms 3420 KB Correct.
5 Correct 625 ms 2896 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 199 ms 3856 KB Correct.
2 Correct 223 ms 3796 KB Correct.
3 Correct 225 ms 3788 KB Correct.
4 Correct 239 ms 10868 KB Correct.
5 Correct 172 ms 2896 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 394 ms 4448 KB Correct.
2 Correct 313 ms 4560 KB Correct.
3 Correct 58 ms 44820 KB Correct.
4 Correct 253 ms 12492 KB Correct.
5 Correct 319 ms 3028 KB Correct.
6 Correct 349 ms 4596 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 787 ms 5972 KB Correct.
2 Correct 115 ms 8384 KB Correct.
3 Correct 2261 ms 57264 KB Correct.
4 Correct 1938 ms 15208 KB Correct.
5 Execution timed out 3065 ms 123200 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 57500 KB Time limit exceeded
2 Halted 0 ms 0 KB -