답안 #1110727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110727 2024-11-10T09:37:27 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
22 / 100
9 ms 27472 KB
/**------------------------------------------
---------Author: BePhuong--------------------
---------From: TK4-CHT ----------------------
---------Training To Win Voi 25 !!! ---------
---------------------------------------------
--------------------PhamVuPhuong2008<BeL>-**/

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define int long long
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define iii pair<int,ii>
#define iv pair<ii, ii>
#define base 341
#define MASK(i) (1ll << i)
#define oo 1e18
#define isOn(x,i) ((x) & MASK(i))
#define bitOn(x,i) ((x) | MASK(i))
#define bitOff(x,i) ((x) & ~MASK(i))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define __lcm(a,b) (1ll * ((a) / __gcd((a), (b))) * (b))
using namespace std;
//using namespace __gnu_pbds;
const int maxn = 1e6 + 5;
int n,m,  dist[maxn], b[maxn];
vector<int> a[maxn];
void djk(int st) {
    for (int i = 1; i <= n; i++) dist[i] = 2e18;
    priority_queue<ii, vector<ii>, greater<ii>> q;
    dist[st] = 0;
    q.push({0, st});
    while(!q.empty()) {
        int cost = q.top().fi, z = q.top().se;
//        int z = q.front();
        q.pop();
        if (cost > dist[z]) continue;
        for (int cost : a[z]) {
            for (int i = 1; z + i*cost <= n; i++) {
                if (dist[z + i*cost] > dist[z] + i) {
                    dist[z + i*cost] = dist[z] + i;
                    q.push({dist[z + i*cost], z + i*cost});
                }
            }
            for (int i = 1; z - i*cost >= 1; i++) {
                if (dist[z - i*cost] > dist[z] + i) {
                    dist[z - i*cost] = dist[z] + i;
                    q.push({dist[z - i*cost], z - i*cost});
                }
            }
        }
    }
}
main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        int x; cin >> x;
        a[b[i]].pb(x);
    }
//    for (int i = 1; i <= n; i++) cout << a[i] << endl;
    djk(b[1]);
    if (dist[b[2]] == 2e18) cout << "-1";
    else cout << dist[b[2]];
}

Compilation message

skyscraper.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27216 KB Output is correct
2 Correct 6 ms 27216 KB Output is correct
3 Correct 6 ms 27384 KB Output is correct
4 Correct 5 ms 27216 KB Output is correct
5 Correct 6 ms 27320 KB Output is correct
6 Correct 4 ms 27268 KB Output is correct
7 Correct 5 ms 27216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27216 KB Output is correct
2 Correct 5 ms 27216 KB Output is correct
3 Correct 5 ms 27216 KB Output is correct
4 Correct 5 ms 27216 KB Output is correct
5 Correct 7 ms 27216 KB Output is correct
6 Correct 5 ms 27216 KB Output is correct
7 Correct 5 ms 27216 KB Output is correct
8 Correct 5 ms 27216 KB Output is correct
9 Correct 5 ms 27216 KB Output is correct
10 Correct 5 ms 27216 KB Output is correct
11 Correct 6 ms 27216 KB Output is correct
12 Correct 5 ms 27216 KB Output is correct
13 Correct 5 ms 27216 KB Output is correct
14 Correct 5 ms 27216 KB Output is correct
15 Correct 5 ms 27268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 27216 KB Output is correct
2 Correct 5 ms 27280 KB Output is correct
3 Correct 5 ms 27380 KB Output is correct
4 Correct 5 ms 27216 KB Output is correct
5 Correct 5 ms 27216 KB Output is correct
6 Correct 5 ms 27216 KB Output is correct
7 Correct 6 ms 27216 KB Output is correct
8 Correct 5 ms 27216 KB Output is correct
9 Correct 6 ms 27216 KB Output is correct
10 Correct 5 ms 27388 KB Output is correct
11 Correct 5 ms 27256 KB Output is correct
12 Correct 6 ms 27384 KB Output is correct
13 Correct 5 ms 27216 KB Output is correct
14 Correct 7 ms 27252 KB Output is correct
15 Correct 6 ms 27216 KB Output is correct
16 Correct 7 ms 27216 KB Output is correct
17 Correct 5 ms 27216 KB Output is correct
18 Correct 6 ms 27216 KB Output is correct
19 Correct 6 ms 27216 KB Output is correct
20 Correct 8 ms 27216 KB Output is correct
21 Correct 5 ms 27216 KB Output is correct
22 Correct 5 ms 27332 KB Output is correct
23 Correct 5 ms 27216 KB Output is correct
24 Correct 5 ms 27216 KB Output is correct
25 Correct 6 ms 27216 KB Output is correct
26 Correct 8 ms 27264 KB Output is correct
27 Correct 8 ms 27216 KB Output is correct
28 Incorrect 5 ms 27228 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 27472 KB Output is correct
2 Correct 5 ms 27216 KB Output is correct
3 Correct 4 ms 27216 KB Output is correct
4 Correct 5 ms 27268 KB Output is correct
5 Correct 4 ms 27216 KB Output is correct
6 Correct 4 ms 27216 KB Output is correct
7 Correct 6 ms 27260 KB Output is correct
8 Correct 5 ms 27216 KB Output is correct
9 Correct 5 ms 27432 KB Output is correct
10 Correct 5 ms 27216 KB Output is correct
11 Correct 5 ms 27216 KB Output is correct
12 Correct 5 ms 27228 KB Output is correct
13 Correct 5 ms 27216 KB Output is correct
14 Correct 6 ms 27384 KB Output is correct
15 Correct 5 ms 27216 KB Output is correct
16 Correct 6 ms 27216 KB Output is correct
17 Correct 6 ms 27216 KB Output is correct
18 Correct 6 ms 27216 KB Output is correct
19 Correct 5 ms 27264 KB Output is correct
20 Correct 9 ms 27216 KB Output is correct
21 Correct 5 ms 27216 KB Output is correct
22 Correct 5 ms 27336 KB Output is correct
23 Correct 6 ms 27384 KB Output is correct
24 Correct 5 ms 27216 KB Output is correct
25 Correct 8 ms 27216 KB Output is correct
26 Correct 8 ms 27216 KB Output is correct
27 Correct 8 ms 27216 KB Output is correct
28 Incorrect 5 ms 27216 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 27268 KB Output is correct
2 Correct 5 ms 27216 KB Output is correct
3 Correct 4 ms 27216 KB Output is correct
4 Correct 5 ms 27216 KB Output is correct
5 Correct 5 ms 27444 KB Output is correct
6 Correct 5 ms 27264 KB Output is correct
7 Correct 5 ms 27216 KB Output is correct
8 Correct 5 ms 27216 KB Output is correct
9 Correct 4 ms 25236 KB Output is correct
10 Correct 5 ms 27216 KB Output is correct
11 Correct 5 ms 27216 KB Output is correct
12 Correct 5 ms 27216 KB Output is correct
13 Correct 5 ms 27216 KB Output is correct
14 Correct 5 ms 27252 KB Output is correct
15 Correct 5 ms 27388 KB Output is correct
16 Correct 4 ms 25196 KB Output is correct
17 Correct 5 ms 27216 KB Output is correct
18 Correct 5 ms 27216 KB Output is correct
19 Correct 5 ms 27216 KB Output is correct
20 Correct 8 ms 27448 KB Output is correct
21 Correct 5 ms 27216 KB Output is correct
22 Correct 5 ms 27216 KB Output is correct
23 Correct 6 ms 27216 KB Output is correct
24 Correct 6 ms 27216 KB Output is correct
25 Correct 6 ms 27216 KB Output is correct
26 Correct 8 ms 27368 KB Output is correct
27 Correct 8 ms 27384 KB Output is correct
28 Incorrect 5 ms 27216 KB Output isn't correct
29 Halted 0 ms 0 KB -