이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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: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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |