이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
#define int int64_t
const int MAXN = 2e5+3;
const int64_t INF = 1e18+69;
int n, m;
vector<pair<int,int>> e[MAXN];
int Start, End, lol, maximum;
int64_t ans;
int64_t f[2][MAXN];
void dijkstra(int s, int64_t f[]){
fill(f+1,f+1+n,INF);
priority_queue<pair<int64_t,int>, vector<pair<int64_t,int>>, greater<pair<int64_t,int>>> pq;
pq.emplace(0, s);
f[s] = 0;
while(!pq.empty()){
pair<int64_t,int> z = pq.top(); pq.pop();
int64_t du = z.first;
int u=z.second;
if(du>f[u])continue;
for(pair<int,int> &z : e[u]){
int v=z.first, w=z.second;
if(f[u]+w<f[v]){
f[v] = f[u]+w;
pq.emplace(f[v], v);
}
}
}
}
signed main()
{
cin.tie(0) -> sync_with_stdio(0);
if(fopen("*.inp", "r")){
freopen("*.inp", "r",stdin);
freopen("*.out", "w",stdout);
}
cin >> n >> m;
cin >> Start >> End >> lol >> maximum;
for(int u, v, w, i=0; i<m; ++i){
cin >> u >> v >> w;
e[u].emplace_back(v, w);
e[v].emplace_back(u, w);
}
dijkstra(Start, f[0]);
dijkstra(End, f[1]);
sort(f[0]+1, f[0]+1+n);
sort(f[1]+1, f[1]+1+n);
for(int i=1; i<=n; ++i){
if(maximum<lol+f[1][i])break;
auto x = upper_bound(f[0]+1, f[0]+1+n, maximum-lol-f[1][i]) - f[0];
ans += x-1;
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | freopen("*.inp", "r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | freopen("*.out", "w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# | 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... |