# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
76762 | antimirage | Evacuation plan (IZhO18_plan) | C++17 | 4101 ms | 24428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 1e5 + 5;
int n, m, x, y, w, ar[N], u[N];
vector < vector <pair <int, int> > > g;
vector < vector <int> > r;
vector < pair <int, pair <int, int> > > vec;
priority_queue <pair <int, int> > q;
void dfs (int v, int porog)
{
u[v] = 1;
for (auto to : g[v])
{
if (u[to.fr] || ar[to.fr] < porog) continue;
dfs(to.fr, porog);
}
}
main()
{
cin >> n >> m;
g.resize(n + 1);
r.resize(n + 1);
for (int i = 1; i <= m; i++)
{
scanf("%d%d%d", &x, &y, &w);
g[x].pb( mk(y, w) );
g[y].pb( mk(x, w) );
}
memset( ar, 0x3f3f3f3f, sizeof(ar) );
cin >> m;
for (int i = 1; i <= m; i++)
{
scanf("%d", &x);
q.push( mk( 0, x ) );
ar[x] = 0;
}
while (!q.empty())
{
w = -q.top().fr, x = q.top().sc;
q.pop();
if (ar[x] < w) continue;
for (auto to : g[x])
{
if (ar[x] + to.sc < ar[to.fr])
{
ar[to.fr] = ar[x] + to.sc;
q.push( mk( -ar[to.fr], to.fr ) );
}
}
}
cin >> m;
while (m--)
{
scanf("%d%d", &x, &y);
int l = 0, r = 1e9 + 7;
while (r - l > 1)
{
int md = (l + r) >> 1;
dfs(x, md);
if (ar[x] >= md && u[y])
l = md;
else
r = md;
for (int j = 1; j <= n; j++) u[j] = 0;
}
printf("%d\n", l);
}
}
/**
9 12
1 9 4
1 2 5
2 3 7
2 4 3
4 3 6
3 6 4
8 7 10
6 7 5
5 8 1
9 5 7
5 4 12
6 8 2
2
4 7
5
1 6
5 3
4 8
5 8
1 5
**/
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |