Submission #953663

# Submission time Handle Problem Language Result Execution time Memory
953663 2024-03-26T12:08:18 Z Unforgettablepl Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 53160 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define int long long

priority_queue<pair<int,pair<int,int>>> q;
vector<int> buildings[30001];
int power[30001];
bool visited[30000][201];
const int INF = 1e15;
int n;
int threshold = 200;

inline void adddoge(int x,int building,int dist){

}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int m;
    cin >> n >> m;
    threshold = sqrt(n);
    int base,tar;
    cin>>base>>power[0]>>tar>>power[1];
    buildings[base].emplace_back(power[0]);
    buildings[tar].emplace_back(power[1]);
    for(int i=2;i<m;i++){
        int b;cin>>b>>power[i];
        buildings[b].emplace_back(power[i]);
    }
    q.emplace(0, make_pair(base,0));
    while(!q.empty()){
        auto curr = q.top();q.pop();
        if(visited[curr.second.first][curr.second.second])continue;
        visited[curr.second.first][curr.second.second]=true;
        if(curr.second.first==tar){
            cout << -curr.first << '\n';
            return 0;
        }
        if(curr.second.second==0)for(int&i:buildings[curr.second.first]) {
            if(i>threshold){
                for (int j = 1; curr.second.first-j*i>= 0; ++j) {
                    int posnext = curr.second.first - j*i;
                    if (!visited[posnext][0])q.emplace(curr.first-j, make_pair(posnext, 0));
                }
                for (int j = 1; curr.second.first+j*i < n; ++j) {
                    int posnext = curr.second.first + j*i;
                    if (!visited[posnext][0])q.emplace(curr.first-j, make_pair(posnext, 0));
                }
            } else {
                if(!visited[curr.second.first][i])q.emplace(curr.first,make_pair(curr.second.first,i));
            }
        }
        else {
            if(!visited[curr.second.first][0])q.emplace(curr.first, make_pair(curr.second.first,0));
            if(curr.second.first+curr.second.second<n and !visited[curr.second.first+curr.second.second][curr.second.second])q.emplace(curr.first-1,make_pair(curr.second.first+curr.second.second,curr.second.second));
            if(curr.second.first-curr.second.second>=0 and !visited[curr.second.first-curr.second.second][curr.second.second])q.emplace(curr.first-1,make_pair(curr.second.first-curr.second.second,curr.second.second));
        }
    }
    cout << "-1\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2908 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2904 KB Output is correct
2 Correct 1 ms 2904 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 3020 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 2 ms 3164 KB Output is correct
15 Correct 1 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2904 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2904 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 1 ms 3164 KB Output is correct
15 Correct 1 ms 3164 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 3164 KB Output is correct
18 Correct 1 ms 2908 KB Output is correct
19 Correct 1 ms 2908 KB Output is correct
20 Correct 1 ms 3420 KB Output is correct
21 Correct 1 ms 2908 KB Output is correct
22 Correct 1 ms 2908 KB Output is correct
23 Correct 2 ms 3160 KB Output is correct
24 Correct 2 ms 3416 KB Output is correct
25 Correct 2 ms 3420 KB Output is correct
26 Correct 1 ms 3232 KB Output is correct
27 Correct 2 ms 3420 KB Output is correct
28 Correct 2 ms 3420 KB Output is correct
29 Correct 7 ms 3420 KB Output is correct
30 Correct 2 ms 3420 KB Output is correct
31 Correct 5 ms 3420 KB Output is correct
32 Correct 4 ms 3612 KB Output is correct
33 Correct 20 ms 4632 KB Output is correct
34 Correct 13 ms 4564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2908 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2904 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2904 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2916 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 2 ms 3168 KB Output is correct
15 Correct 1 ms 3168 KB Output is correct
16 Correct 1 ms 2912 KB Output is correct
17 Correct 2 ms 3164 KB Output is correct
18 Correct 1 ms 2912 KB Output is correct
19 Correct 1 ms 2912 KB Output is correct
20 Correct 1 ms 3424 KB Output is correct
21 Correct 1 ms 2920 KB Output is correct
22 Correct 1 ms 2912 KB Output is correct
23 Correct 2 ms 3164 KB Output is correct
24 Correct 2 ms 3424 KB Output is correct
25 Correct 2 ms 3424 KB Output is correct
26 Correct 1 ms 3420 KB Output is correct
27 Correct 1 ms 3420 KB Output is correct
28 Correct 2 ms 3420 KB Output is correct
29 Correct 7 ms 3420 KB Output is correct
30 Correct 3 ms 3424 KB Output is correct
31 Correct 5 ms 3424 KB Output is correct
32 Correct 3 ms 3616 KB Output is correct
33 Correct 17 ms 4564 KB Output is correct
34 Correct 12 ms 4568 KB Output is correct
35 Correct 6 ms 4384 KB Output is correct
36 Correct 3 ms 3164 KB Output is correct
37 Correct 5 ms 4440 KB Output is correct
38 Correct 8 ms 5328 KB Output is correct
39 Correct 7 ms 3420 KB Output is correct
40 Correct 5 ms 4244 KB Output is correct
41 Correct 9 ms 5332 KB Output is correct
42 Correct 4 ms 3568 KB Output is correct
43 Correct 4 ms 3548 KB Output is correct
44 Correct 4 ms 3588 KB Output is correct
45 Correct 87 ms 16332 KB Output is correct
46 Correct 50 ms 16844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2908 KB Output is correct
2 Correct 1 ms 2912 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2912 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2912 KB Output is correct
7 Correct 1 ms 2912 KB Output is correct
8 Correct 1 ms 3164 KB Output is correct
9 Correct 1 ms 2912 KB Output is correct
10 Correct 1 ms 2912 KB Output is correct
11 Correct 1 ms 2912 KB Output is correct
12 Correct 1 ms 2936 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 1 ms 3168 KB Output is correct
15 Correct 1 ms 3164 KB Output is correct
16 Correct 1 ms 2912 KB Output is correct
17 Correct 2 ms 3164 KB Output is correct
18 Correct 2 ms 2908 KB Output is correct
19 Correct 1 ms 2908 KB Output is correct
20 Correct 1 ms 3420 KB Output is correct
21 Correct 1 ms 2908 KB Output is correct
22 Correct 1 ms 2908 KB Output is correct
23 Correct 2 ms 3164 KB Output is correct
24 Correct 2 ms 3420 KB Output is correct
25 Correct 1 ms 3420 KB Output is correct
26 Correct 1 ms 3420 KB Output is correct
27 Correct 1 ms 3420 KB Output is correct
28 Correct 2 ms 3420 KB Output is correct
29 Correct 7 ms 3416 KB Output is correct
30 Correct 2 ms 3420 KB Output is correct
31 Correct 5 ms 3512 KB Output is correct
32 Correct 5 ms 3612 KB Output is correct
33 Correct 22 ms 4568 KB Output is correct
34 Correct 12 ms 4564 KB Output is correct
35 Correct 6 ms 4444 KB Output is correct
36 Correct 2 ms 3164 KB Output is correct
37 Correct 5 ms 4444 KB Output is correct
38 Correct 8 ms 5328 KB Output is correct
39 Correct 5 ms 3420 KB Output is correct
40 Correct 5 ms 4188 KB Output is correct
41 Correct 8 ms 5332 KB Output is correct
42 Correct 4 ms 3548 KB Output is correct
43 Correct 4 ms 3800 KB Output is correct
44 Correct 4 ms 3588 KB Output is correct
45 Correct 91 ms 17944 KB Output is correct
46 Correct 50 ms 17096 KB Output is correct
47 Correct 9 ms 6980 KB Output is correct
48 Correct 4 ms 3416 KB Output is correct
49 Correct 4 ms 3420 KB Output is correct
50 Correct 6 ms 3164 KB Output is correct
51 Correct 14 ms 8748 KB Output is correct
52 Correct 17 ms 9428 KB Output is correct
53 Correct 10 ms 4328 KB Output is correct
54 Correct 4 ms 7260 KB Output is correct
55 Correct 4 ms 7216 KB Output is correct
56 Correct 8 ms 8028 KB Output is correct
57 Correct 1 ms 3164 KB Output is correct
58 Correct 10 ms 8664 KB Output is correct
59 Correct 8 ms 7644 KB Output is correct
60 Correct 8 ms 7648 KB Output is correct
61 Correct 8 ms 7688 KB Output is correct
62 Correct 19 ms 8028 KB Output is correct
63 Correct 346 ms 28604 KB Output is correct
64 Correct 379 ms 29380 KB Output is correct
65 Execution timed out 1020 ms 53160 KB Time limit exceeded
66 Halted 0 ms 0 KB -