Submission #749433

# Submission time Handle Problem Language Result Execution time Memory
749433 2023-05-28T03:17:38 Z yellowtoad Cyberland (APIO23_cyberland) C++17
0 / 100
2213 ms 890192 KB
#include "cyberland.h"
#include <iostream>
#include <vector>
#include <queue>
#define edgetype pair<pair<int,int>,long double>
#define distype pair<long double,pair<int,int>>
#define f first
#define s second
using namespace std;

long long n, m, k, h;
pair<int,int> u, v;
long double canvis[1][100010], dist[130][100010], w, minn = 1e18;
bool vis[130][100010];
vector<edgetype> edge[130][100010];
priority_queue<distype,vector<distype>,greater<distype>> pq;

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) {
    n = N; m = M; k = K; h = H;
    for (int i = 0; i <= min(k,60LL)*2; i++) for (int j = 0; j < n; j++) edge[i][j].clear();
    for (int i = 0; i < m; i++) {
        edge[0][x[i]].push_back({{0,y[i]},c[i]});
        edge[0][y[i]].push_back({{0,x[i]},c[i]});
    }
    for (int i = 0; i < n; i++) {
        vis[0][i] = 0;
        canvis[0][i] = 1e18;
    }
    vis[0][h] = 1;
    canvis[0][0] = 0;
    pq.push({0,{0,0}});
    while (pq.size()) {
        u = pq.top().s;
        pq.pop();
        if (vis[u.f][u.s]) continue;
        vis[u.f][u.s] = 1;
        for (int i = 0; i < edge[u.f][u.s].size(); i++) {
            v = edge[u.f][u.s][i].f;
            w = edge[u.f][u.s][i].s;
            if (canvis[v.f][v.s] > canvis[u.f][u.s]+w) {
                canvis[v.f][v.s] = canvis[u.f][u.s]+w;
                pq.push({canvis[v.f][v.s],v});
            }
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 1; j <= min(k,60LL)*2; j++) {
            edge[j][x[i]].push_back({{j,y[i]},c[i]/(1<<(j/2))});
            edge[j][y[i]].push_back({{j,x[i]},c[i]/(1<<(j/2))});
        }
    }
    for (int i = 0; i < n; i++) {
        if (arr[i] == 2) for (int j = 1; j < min(k,60LL)*2; ++++j) edge[j][i].push_back({{j+1,i},0});
        else for (int j = 0; j < min(k,60LL)*2; ++++j) edge[j][i].push_back({{j+1,i},0});
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= min(k,60LL)*2; j++) {
            vis[j][i] = 0;
            dist[j][i] = 1e18;
        }
    }
    dist[0][h] = 0;
    pq.push({0,{0,h}});
    while (pq.size()) {
        u = pq.top().s;
        pq.pop();
        if (vis[u.f][u.s]) continue;
        vis[u.f][u.s] = 1;
        for (int i = 0; i < edge[u.f][u.s].size(); i++) {
            v = edge[u.f][u.s][i].f;
            w = edge[u.f][u.s][i].s;
            if (dist[v.f][v.s] > dist[u.f][u.s]+w) {
                dist[v.f][v.s] = dist[u.f][u.s]+w;
                pq.push({dist[v.f][v.s],v});
            }
        }
    }
    for (int j = 0; j <= min(k,60LL)*2; j++) minn = min(minn,dist[j][0]);
    for (int i = 0; i < n; i++) if ((arr[i] == 0) && (canvis[0][i] != 1e18)) for (int j = 0; j <= min(k,60LL)*2; j++) minn = min(minn,dist[j][i]);
    if (minn != 1e18) return minn;
    else return -1;
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:37:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i = 0; i < edge[u.f][u.s].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~
cyberland.cpp:69:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         for (int i = 0; i < edge[u.f][u.s].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 199 ms 306512 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 396 ms 319656 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 452 ms 319584 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2213 ms 890192 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 401 ms 329316 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 468 ms 330520 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 967 ms 330856 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1937 ms 355344 KB Wrong Answer.
2 Halted 0 ms 0 KB -