Submission #953647

# Submission time Handle Problem Language Result Execution time Memory
953647 2024-03-26T11:45:17 Z Unforgettablepl Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
264 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

priority_queue<pair<int,int>> q;
vector<pair<int,int>> adj[6000000];
bool visited[6000000];
int n;
const int threshold = 173;

void adddoge(int power,int building){
    if(power>threshold){
        int minimum = building - power*(building/power);
        for (int i = minimum; i < n; i += power)
            adj[building*174].emplace_back(i*174,abs(building-i)/power);
    } else {
        adj[building*174].emplace_back(building*174+power,0);
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int m;
    cin >> n >> m;
    int base,tar,bp,tp;
    cin>>base>>bp>>tar>>tp;
    adddoge(bp,base);
    adddoge(tp,tar);
    for(int i=2;i<m;i++){
        int b,p;cin>>b>>p;
        adddoge(p,b);
    }
    for(int i=0;i<n;i++){
        int b = i*174;
        for(int j=b+1;j<b+174;j++){
            adj[j].emplace_back(b,0);
        }
    }
    for(int power=1;power<=173;power++){
        int offset = 174*power;
        for(int i=power;i<n;i++){
            adj[i*174+power].emplace_back(i*174+power-offset,1);
        }
        for(int i=n-power-1;i>=0;i--){
            adj[i*174+power].emplace_back(i*174+power+offset,1);
        }
    }
    base*=174;tar*=174;
    q.emplace(0, base);
    while(!q.empty()){
        auto curr = q.top();q.pop();
        if(visited[curr.second])continue;
        visited[curr.second]=true;
        if(curr.second==tar){
            cout << -curr.first << '\n';
            return 0;
        }
        for(auto&i:adj[curr.second])if(!visited[i.first])q.emplace(curr.first-i.second,i.first);
    }
    cout << "-1\n";
}
# Verdict Execution time Memory Grader output
1 Correct 66 ms 142952 KB Output is correct
2 Correct 59 ms 143020 KB Output is correct
3 Correct 50 ms 142932 KB Output is correct
4 Correct 49 ms 142912 KB Output is correct
5 Correct 50 ms 142928 KB Output is correct
6 Correct 49 ms 142932 KB Output is correct
7 Correct 54 ms 143228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 142804 KB Output is correct
2 Correct 48 ms 142932 KB Output is correct
3 Correct 53 ms 142880 KB Output is correct
4 Correct 48 ms 142932 KB Output is correct
5 Correct 49 ms 142952 KB Output is correct
6 Correct 56 ms 142932 KB Output is correct
7 Correct 48 ms 142932 KB Output is correct
8 Correct 49 ms 142928 KB Output is correct
9 Correct 56 ms 143272 KB Output is correct
10 Correct 54 ms 143696 KB Output is correct
11 Correct 49 ms 143700 KB Output is correct
12 Correct 50 ms 143700 KB Output is correct
13 Correct 49 ms 143700 KB Output is correct
14 Correct 52 ms 143784 KB Output is correct
15 Correct 50 ms 143696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 142856 KB Output is correct
2 Correct 49 ms 142744 KB Output is correct
3 Correct 51 ms 142924 KB Output is correct
4 Correct 50 ms 142932 KB Output is correct
5 Correct 49 ms 142932 KB Output is correct
6 Correct 49 ms 142940 KB Output is correct
7 Correct 48 ms 142980 KB Output is correct
8 Correct 49 ms 142932 KB Output is correct
9 Correct 49 ms 143228 KB Output is correct
10 Correct 49 ms 143708 KB Output is correct
11 Correct 49 ms 143804 KB Output is correct
12 Correct 50 ms 143696 KB Output is correct
13 Correct 49 ms 143680 KB Output is correct
14 Correct 52 ms 144072 KB Output is correct
15 Correct 51 ms 143772 KB Output is correct
16 Correct 57 ms 144756 KB Output is correct
17 Correct 71 ms 152628 KB Output is correct
18 Correct 102 ms 166696 KB Output is correct
19 Correct 129 ms 170084 KB Output is correct
20 Correct 109 ms 170576 KB Output is correct
21 Correct 61 ms 147480 KB Output is correct
22 Correct 101 ms 166996 KB Output is correct
23 Correct 111 ms 164692 KB Output is correct
24 Correct 129 ms 169208 KB Output is correct
25 Correct 128 ms 170980 KB Output is correct
26 Correct 108 ms 170484 KB Output is correct
27 Correct 115 ms 170424 KB Output is correct
28 Correct 117 ms 170476 KB Output is correct
29 Correct 135 ms 170576 KB Output is correct
30 Correct 116 ms 170444 KB Output is correct
31 Correct 138 ms 170492 KB Output is correct
32 Correct 144 ms 170580 KB Output is correct
33 Correct 144 ms 170576 KB Output is correct
34 Correct 136 ms 170580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 142936 KB Output is correct
2 Correct 47 ms 142936 KB Output is correct
3 Correct 48 ms 142896 KB Output is correct
4 Correct 48 ms 142936 KB Output is correct
5 Correct 48 ms 142928 KB Output is correct
6 Correct 48 ms 142928 KB Output is correct
7 Correct 54 ms 142860 KB Output is correct
8 Correct 50 ms 143160 KB Output is correct
9 Correct 49 ms 143200 KB Output is correct
10 Correct 49 ms 143696 KB Output is correct
11 Correct 50 ms 143808 KB Output is correct
12 Correct 51 ms 143588 KB Output is correct
13 Correct 53 ms 143784 KB Output is correct
14 Correct 50 ms 143880 KB Output is correct
15 Correct 50 ms 143816 KB Output is correct
16 Correct 53 ms 144724 KB Output is correct
17 Correct 72 ms 152624 KB Output is correct
18 Correct 111 ms 166812 KB Output is correct
19 Correct 118 ms 169968 KB Output is correct
20 Correct 110 ms 170628 KB Output is correct
21 Correct 67 ms 147472 KB Output is correct
22 Correct 103 ms 167240 KB Output is correct
23 Correct 113 ms 164740 KB Output is correct
24 Correct 124 ms 169296 KB Output is correct
25 Correct 116 ms 170580 KB Output is correct
26 Correct 109 ms 170324 KB Output is correct
27 Correct 112 ms 170508 KB Output is correct
28 Correct 119 ms 170404 KB Output is correct
29 Correct 132 ms 170512 KB Output is correct
30 Correct 112 ms 170580 KB Output is correct
31 Correct 139 ms 170584 KB Output is correct
32 Correct 131 ms 170492 KB Output is correct
33 Correct 146 ms 170576 KB Output is correct
34 Correct 145 ms 170580 KB Output is correct
35 Correct 117 ms 164144 KB Output is correct
36 Correct 85 ms 157780 KB Output is correct
37 Correct 129 ms 171980 KB Output is correct
38 Correct 142 ms 173152 KB Output is correct
39 Correct 134 ms 172120 KB Output is correct
40 Correct 137 ms 172628 KB Output is correct
41 Correct 138 ms 173004 KB Output is correct
42 Correct 113 ms 171044 KB Output is correct
43 Correct 117 ms 170960 KB Output is correct
44 Correct 119 ms 170976 KB Output is correct
45 Correct 212 ms 177916 KB Output is correct
46 Correct 178 ms 177864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 142932 KB Output is correct
2 Correct 50 ms 142924 KB Output is correct
3 Correct 52 ms 143200 KB Output is correct
4 Correct 48 ms 142932 KB Output is correct
5 Correct 48 ms 142984 KB Output is correct
6 Correct 48 ms 142928 KB Output is correct
7 Correct 47 ms 142928 KB Output is correct
8 Correct 49 ms 142932 KB Output is correct
9 Correct 48 ms 143376 KB Output is correct
10 Correct 51 ms 143696 KB Output is correct
11 Correct 50 ms 143696 KB Output is correct
12 Correct 51 ms 143700 KB Output is correct
13 Correct 49 ms 143700 KB Output is correct
14 Correct 52 ms 143700 KB Output is correct
15 Correct 54 ms 143868 KB Output is correct
16 Correct 54 ms 144636 KB Output is correct
17 Correct 71 ms 152624 KB Output is correct
18 Correct 102 ms 166484 KB Output is correct
19 Correct 118 ms 170064 KB Output is correct
20 Correct 112 ms 170624 KB Output is correct
21 Correct 59 ms 147536 KB Output is correct
22 Correct 105 ms 167120 KB Output is correct
23 Correct 130 ms 164708 KB Output is correct
24 Correct 139 ms 169244 KB Output is correct
25 Correct 114 ms 170436 KB Output is correct
26 Correct 113 ms 170324 KB Output is correct
27 Correct 121 ms 170504 KB Output is correct
28 Correct 119 ms 170536 KB Output is correct
29 Correct 140 ms 170524 KB Output is correct
30 Correct 121 ms 170580 KB Output is correct
31 Correct 139 ms 170464 KB Output is correct
32 Correct 135 ms 170320 KB Output is correct
33 Correct 151 ms 170648 KB Output is correct
34 Correct 139 ms 170484 KB Output is correct
35 Correct 106 ms 164096 KB Output is correct
36 Correct 89 ms 157788 KB Output is correct
37 Correct 130 ms 172208 KB Output is correct
38 Correct 140 ms 173004 KB Output is correct
39 Correct 135 ms 172188 KB Output is correct
40 Correct 140 ms 172624 KB Output is correct
41 Correct 146 ms 173056 KB Output is correct
42 Correct 117 ms 171188 KB Output is correct
43 Correct 116 ms 171172 KB Output is correct
44 Correct 115 ms 170972 KB Output is correct
45 Correct 223 ms 178108 KB Output is correct
46 Correct 178 ms 177772 KB Output is correct
47 Runtime error 264 ms 262144 KB Execution killed with signal 9
48 Halted 0 ms 0 KB -