답안 #975804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975804 2024-05-05T22:55:58 Z andro Jakarta Skyscrapers (APIO15_skyscraper) C++14
22 / 100
56 ms 69352 KB
#include <bits/stdc++.h>
 
#define int long long
 
#define ll long long
 
using namespace std;
 
const int N = 30005;
 
vector<pair<ll,ll>>G[N];
vector<ll>dist(N,1e18),par(N,-1);
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> a(m);
    for(int i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
    }
    for(int i = 0; i < m; i++) {
        for(int j = 1; j < 1000; j++) {
            if(a[i].first - j * a[i].second >= 0) {
                G[a[i].first].push_back({a[i].first - j * a[i].second, j});
            }
            if(a[i].first + j * a[i].second <= n) {
                G[a[i].first].push_back({a[i].first + j * a[i].second, j});
            }
        }
    }
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>pq;
    pq.push({0,a[0].first});
    dist[a[0].first] = 0;
    vector<bool>vis(n+1,false);
    while(pq.size()) {
        ll d,u;
        tie(d,u) = pq.top();
        pq.pop();
        if(vis[u]) continue;
        vis[u] = true;
        for(auto X:G[u]) {
            if(dist[X.first] > dist[u] + X.second) {
                dist[X.first] = dist[u] + X.second;
                pq.push({dist[X.first],X.first});
                par[X.first] = u;
            }
        }
    }
    if(dist[a[1].first] == 1e18) {
        cout << - 1;
    }
    else {
        cout << dist[a[1].first];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1624 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1624 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 1628 KB Output is correct
11 Correct 5 ms 1916 KB Output is correct
12 Correct 7 ms 5836 KB Output is correct
13 Correct 7 ms 7116 KB Output is correct
14 Correct 3 ms 1628 KB Output is correct
15 Correct 3 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1624 KB Output is correct
9 Correct 1 ms 1624 KB Output is correct
10 Correct 2 ms 1652 KB Output is correct
11 Correct 3 ms 1880 KB Output is correct
12 Correct 7 ms 6092 KB Output is correct
13 Correct 7 ms 7272 KB Output is correct
14 Correct 4 ms 1624 KB Output is correct
15 Correct 3 ms 1628 KB Output is correct
16 Correct 2 ms 1788 KB Output is correct
17 Correct 3 ms 2140 KB Output is correct
18 Correct 2 ms 1656 KB Output is correct
19 Correct 2 ms 1628 KB Output is correct
20 Correct 55 ms 55828 KB Output is correct
21 Correct 2 ms 1624 KB Output is correct
22 Correct 3 ms 1628 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 3 ms 1884 KB Output is correct
25 Correct 3 ms 1880 KB Output is correct
26 Correct 34 ms 35780 KB Output is correct
27 Correct 50 ms 68764 KB Output is correct
28 Correct 3 ms 2140 KB Output is correct
29 Incorrect 4 ms 3164 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1400 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 3 ms 1728 KB Output is correct
12 Correct 7 ms 7116 KB Output is correct
13 Correct 6 ms 5836 KB Output is correct
14 Correct 4 ms 1628 KB Output is correct
15 Correct 3 ms 1628 KB Output is correct
16 Correct 2 ms 1628 KB Output is correct
17 Correct 3 ms 2140 KB Output is correct
18 Correct 3 ms 1628 KB Output is correct
19 Correct 1 ms 1628 KB Output is correct
20 Correct 52 ms 55824 KB Output is correct
21 Correct 2 ms 1628 KB Output is correct
22 Correct 2 ms 1628 KB Output is correct
23 Correct 2 ms 1624 KB Output is correct
24 Correct 4 ms 1880 KB Output is correct
25 Correct 3 ms 1884 KB Output is correct
26 Correct 31 ms 36064 KB Output is correct
27 Correct 46 ms 68244 KB Output is correct
28 Correct 4 ms 2136 KB Output is correct
29 Incorrect 4 ms 3164 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1632 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1632 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 2 ms 1628 KB Output is correct
10 Correct 2 ms 1628 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 9 ms 7116 KB Output is correct
13 Correct 7 ms 6344 KB Output is correct
14 Correct 3 ms 1628 KB Output is correct
15 Correct 3 ms 1628 KB Output is correct
16 Correct 2 ms 1628 KB Output is correct
17 Correct 3 ms 2140 KB Output is correct
18 Correct 2 ms 1628 KB Output is correct
19 Correct 2 ms 1628 KB Output is correct
20 Correct 56 ms 55656 KB Output is correct
21 Correct 2 ms 1624 KB Output is correct
22 Correct 2 ms 1624 KB Output is correct
23 Correct 2 ms 1784 KB Output is correct
24 Correct 3 ms 1880 KB Output is correct
25 Correct 3 ms 1884 KB Output is correct
26 Correct 33 ms 36544 KB Output is correct
27 Correct 46 ms 69352 KB Output is correct
28 Correct 4 ms 1920 KB Output is correct
29 Incorrect 4 ms 3160 KB Output isn't correct
30 Halted 0 ms 0 KB -