| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 660776 | danikoynov | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 94 ms | 64596 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 2010;
const ll inf = 1e18;
struct doge
{
int b, p;
}d[maxn];
struct edge
{
int u;
ll w;
edge(int _u, ll _w)
{
u = _u;
w = _w;
}
bool operator < (const edge &e) const
{
return w > e.w;
}
};
vector < edge > g[maxn];
int n, m, used[maxn];
ll dp[maxn];
void dijkstra(int s)
{
for (int i = 0; i < m; i ++)
{
used[i] = 0;
dp[i] = inf;
}
priority_queue < edge > pq;
pq.push(edge(0, 0));
dp[0] = 0;
while(!pq.empty())
{
edge cur = pq.top();
pq.pop();
if (!used[cur.u])
{
used[cur.u] = 1;
for (int i = 0; i < g[cur.u].size(); i ++)
{
edge nb = g[cur.u][i];
nb.w += cur.w;
if (nb.w < dp[nb.u])
{
dp[nb.u] = nb.w;
pq.push(nb);
}
}
}
}
}
void solve()
{
cin >> n >> m;
for (int i = 0; i < m; i ++)
{
cin >> d[i].b >> d[i].p;
}
for (int i = 0; i < m; i ++)
for (int j = 0; j < m; j ++)
{
if (i == j)
continue;
int dis = abs(d[i].b - d[j].b);
if (dis % d[i].p == 0)
g[i].push_back(edge(j, dis / d[i].p));
}
dijkstra(0);
if (dp[1] == inf)
cout << -1 << endl;
else
cout << dp[1] << endl;
}
int main()
{
solve();
return 0;
}
컴파일 시 표준 에러 (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... | ||||
