Submission #695237

# Submission time Handle Problem Language Result Execution time Memory
695237 2023-02-04T20:10:23 Z Mizo_Compiler Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
235 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
#define MOEZ ios_base::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(v) v.begin() , v.end()
#define eb emplace_back
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define mem(d , x) memset(d , x , sizeof(d));
#define sz(x) (int)x.size()
const int N = 2e5+5;
//const ll M = 1e9+7;
//const ll inf = 1e18;
//const ld eps = 1e-6;
#define int long long
int n , id[N] , p[N] , m;
vector<pair<int , int>>adj[N];
int d[N];
signed main(){
    MOEZ
    cin >> n >> m;
    for(int i = 0; i < n;i++){
        d[i] = 1e18;
    }
    for(int i = 0; i < m;i++){
        cin >> id[i];
        cin >> p[i];
        int cnt = 1;
        for(int j = id[i]+p[i]; j < n;j += p[i]){
            adj[id[i]].pb({j , cnt++});
        }
        cnt = 1;
        for(int j = id[i]-p[i]; j >= 0;j -= p[i]){
            adj[id[i]].pb({j , cnt++});
        }
    }
    priority_queue<pair<int , int> , vector<pair<int , int>> , greater<>>q;
    q.push({id[0] , 0});
    d[id[0]] = 0;
    while(!q.empty()){
        int u = q.top().F , cost = q.top().S;
        q.pop();
        if(d[u] < cost)continue;
        for(auto x:adj[u]){
            int v = x.F , nc = cost+x.S;
            if(nc < d[v]){
                d[v] = nc;
                q.push({v , nc});
            }
        }
    }
    cout << (d[id[1]] == 1e18 ? -1 : d[id[1]]);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 4 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 4 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5032 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 3 ms 5204 KB Output is correct
12 Correct 8 ms 9292 KB Output is correct
13 Correct 7 ms 9232 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 2 ms 4960 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 4 ms 5204 KB Output is correct
12 Correct 7 ms 9292 KB Output is correct
13 Correct 7 ms 9296 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 4 ms 5588 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 69 ms 69232 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 4 ms 5204 KB Output is correct
24 Correct 5 ms 5460 KB Output is correct
25 Correct 5 ms 5204 KB Output is correct
26 Correct 98 ms 71092 KB Output is correct
27 Correct 84 ms 70920 KB Output is correct
28 Correct 3 ms 5460 KB Output is correct
29 Correct 5 ms 6740 KB Output is correct
30 Correct 4 ms 5716 KB Output is correct
31 Correct 4 ms 5972 KB Output is correct
32 Correct 4 ms 5716 KB Output is correct
33 Correct 6 ms 8020 KB Output is correct
34 Correct 7 ms 7888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 3 ms 5204 KB Output is correct
12 Correct 7 ms 9292 KB Output is correct
13 Correct 9 ms 9296 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
16 Correct 4 ms 5076 KB Output is correct
17 Correct 5 ms 5588 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 73 ms 69284 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 4 ms 5204 KB Output is correct
24 Correct 5 ms 5456 KB Output is correct
25 Correct 5 ms 5292 KB Output is correct
26 Correct 87 ms 71032 KB Output is correct
27 Correct 82 ms 70912 KB Output is correct
28 Correct 3 ms 5460 KB Output is correct
29 Correct 5 ms 6740 KB Output is correct
30 Correct 4 ms 5716 KB Output is correct
31 Correct 4 ms 5972 KB Output is correct
32 Correct 3 ms 5716 KB Output is correct
33 Correct 7 ms 7996 KB Output is correct
34 Correct 7 ms 7888 KB Output is correct
35 Correct 11 ms 8560 KB Output is correct
36 Correct 5 ms 5552 KB Output is correct
37 Correct 20 ms 12252 KB Output is correct
38 Correct 16 ms 10788 KB Output is correct
39 Correct 16 ms 11344 KB Output is correct
40 Correct 16 ms 10900 KB Output is correct
41 Correct 16 ms 10680 KB Output is correct
42 Runtime error 223 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4940 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 3 ms 5204 KB Output is correct
12 Correct 7 ms 9292 KB Output is correct
13 Correct 7 ms 9296 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5076 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 6 ms 5556 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 72 ms 69248 KB Output is correct
21 Correct 2 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 4 ms 5204 KB Output is correct
24 Correct 6 ms 5332 KB Output is correct
25 Correct 6 ms 5204 KB Output is correct
26 Correct 89 ms 71072 KB Output is correct
27 Correct 84 ms 70972 KB Output is correct
28 Correct 4 ms 5460 KB Output is correct
29 Correct 6 ms 6764 KB Output is correct
30 Correct 4 ms 5716 KB Output is correct
31 Correct 4 ms 5972 KB Output is correct
32 Correct 4 ms 5716 KB Output is correct
33 Correct 7 ms 8020 KB Output is correct
34 Correct 7 ms 7892 KB Output is correct
35 Correct 11 ms 8652 KB Output is correct
36 Correct 4 ms 5552 KB Output is correct
37 Correct 16 ms 12244 KB Output is correct
38 Correct 16 ms 10712 KB Output is correct
39 Correct 17 ms 11344 KB Output is correct
40 Correct 16 ms 10928 KB Output is correct
41 Correct 15 ms 10600 KB Output is correct
42 Runtime error 235 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -