답안 #981937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981937 2024-05-13T16:49:20 Z Abito 자매 도시 (APIO20_swap) C++17
0 / 100
84 ms 56320 KB
#include "swap.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define ep insert
#define pb push_back
using namespace std;
const int NN=1e3+5;
int n,m,dis[5][NN][NN],q;
vector<pair<int,int>> adj[NN];
bool vis[5][NN][NN];
void dijkstra(int X,int Y){
    dis[5][X][Y]=0;
    priority_queue<vector<int>> pq;
    pq.push({0,X,Y});
    while (!pq.empty()){
        int i=pq.top()[1],j=pq.top()[2];
        pq.pop();
        if (vis[q][i][j]) continue;
        vis[q][i][j]=1;
        for (auto u:adj[i]){
            if (u.F==j) continue;
            int d=max(dis[q][i][j],u.S);
            if (d<dis[q][u.F][j] || dis[q][u.F][j]<0){
                dis[q][u.F][j]=d;
                pq.push({-d,u.F,j});
            }
        }
        for (auto u:adj[j]){
            if (u.F==i) continue;
            int d=max(dis[q][i][j],u.S);
            if (d<dis[q][i][u.F] || dis[q][i][u.F]<0){
                dis[q][i][u.F]=d;
                pq.push({-d,i,u.F});
            }
        }
    }return;
}
void init(int N, int M,
          vector<int> U, vector<int> V, vector<int> W) {
    n=N,m=M;
    for (int i=0;i<m;i++){
        adj[U[i]].pb({V[i],W[i]});
        adj[V[i]].pb({U[i],W[i]});
    }
    memset(dis,-1,sizeof(dis));
    return;
}

int getMinimumFuelCapacity(int X, int Y) {
    dijkstra(X,Y);
    /*for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            cout<<dis[i][j]<<' ';
        }cout<<endl;
    }*/
    return dis[q++][Y][X];
}

Compilation message

swap.cpp: In function 'void dijkstra(int, int)':
swap.cpp:13:10: warning: array subscript 5 is above array bounds of 'int [5][1005][1005]' [-Warray-bounds]
   13 |     dis[5][X][Y]=0;
      |     ~~~~~^
swap.cpp:9:9: note: while referencing 'dis'
    9 | int n,m,dis[5][NN][NN],q;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 20768 KB Output is correct
3 Correct 3 ms 20828 KB Output is correct
4 Runtime error 21 ms 42112 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 20768 KB Output is correct
3 Runtime error 84 ms 56320 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 20768 KB Output is correct
3 Correct 3 ms 20828 KB Output is correct
4 Runtime error 21 ms 42112 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 20768 KB Output is correct
3 Correct 3 ms 20828 KB Output is correct
4 Runtime error 21 ms 42112 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 20768 KB Output is correct
3 Correct 3 ms 20828 KB Output is correct
4 Runtime error 21 ms 42112 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 20768 KB Output is correct
3 Correct 3 ms 20828 KB Output is correct
4 Runtime error 21 ms 42112 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -