이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ve vector
#define vi vector<int>
#define vii vector<ii>
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define INF 1e18+7
#define pb push_back
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
const int MOD = 1e9+7;
const int nax = 2e5+5;
const int MAXL = 20+5;
void readio(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
#include "cyberland.h"
int par[nax];
int findpar(int u){
if(par[u] == u) return u;
return par[u] = findpar(par[u]);
}
bool isSameSet(int u, int v){
return (findpar(u) == findpar(v));
}
void unionSet(int u, int v){
u = findpar(u), v = findpar(v);
if(u != v) par[u] = v;
}
vii adj[nax];
bool vis[nax];
void dfs(int u, int nt){
if(vis[u]) return;
vis[u] = 1;
for(auto x : adj[u]){
if(x.fi == nt) continue;
dfs(x.fi, nt);
}
}
double solve(int n, int m, int k, int h, vi x, vi y, vi c, vi arr) {
for (int i = 0; i < n; ++i)
{
adj[i].clear();
par[i] = i;
vis[i] = 0;
}
for (int i = 0; i < m; ++i)
{
adj[x[i]].pb({y[i], c[i]});
adj[y[i]].pb({x[i], c[i]});
}
dfs(0,h);
ve<double> dist(n, INF);
priority_queue<pair<pair<ll,int>,int>, ve<pair<pair<ll,int>,int>>, greater<pair<pair<ll,int>,int>>> pq;
for (int i = 0; i < n; ++i)
{
if((arr[i] == 0 && vis[i])|| !i){
dist[i] =0;
pq.push({{0,0}, i});
}
}
while(!pq.empty()){
int u = pq.top().se, nb = pq.top().fi.se;
ll cst = pq.top().fi.fi;
pq.pop();
if(dist[u] != cst) continue;
for(auto x : adj[u]){
if(dist[u]+x.se < dist[x.fi]){
dist[x.fi] = dist[u]+x.se;
pq.push({{dist[x.fi], nb}, x.fi});
if(nb < k) pq.push({{dist[x.fi]/2., nb+1}, x.fi});
}
}
}
if(dist[h] == INF) return -1;
return dist[h];
}
컴파일 시 표준 에러 (stderr) 메시지
cyberland.cpp: In function 'void readio()':
cyberland.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cyberland.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | freopen("output.txt", "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... |
# | 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... |