Submission #207779

# Submission time Handle Problem Language Result Execution time Memory
207779 2020-03-08T23:24:05 Z mohamedsobhi777 Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
398 ms 262148 KB
#include<bits/stdc++.h> 
 
using namespace std ;

const int N = 3e5 + 7 ; 

int n  , m ;

int b[N] , p[N] , d[N]; 

vector<pair<int , int > > adj[N] ; 

int dijkstra() 
{
    memset(d , -1 , sizeof d) ; 
    priority_queue<pair<int , int > > q ; 
    q.push({0 , b[0]}) ;
    d[ b[0] ] = 0; 
    while(q.size())
    {
        int  node = q .top().second ; 
        int dist = -q.top().first ; 
        q.pop();
        for(auto u : adj[node])
        {
            if(d[u.first]==-1 || dist + u.second < d[u.first])
            {
                d[u.first] = dist + u.second ; 
                q.push({-d[u.first] , u.first}) ; 
            }
        }
    }

    return d[ b[1] ] ; 
}


int main() 
{
    //freopen("in.in" , "r",  stdin) ; 
    cin>>n>>m ; 
    for(int i = 0 ; i < N ;i++)
        b[i] = n;
    for(int i= 0 ; i <  m ; i++)
    {
        int A , B;  
        cin>>A>>B ; 
        b[ i ] = A;
        if(!B)
        continue;
        for(int j = 0 ; j < n ; j++)
        {
            if(A==j)
                continue;
            if(j==A)
            continue;
            if(abs(A-j)%B==0)
            {
                adj[A].push_back({j , abs(A-j)/B});
            }
        }
    }
    cout<<dijkstra();
    return 0 ;  
}

# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 10 ms 9720 KB Output is correct
5 Correct 10 ms 9720 KB Output is correct
6 Correct 11 ms 9720 KB Output is correct
7 Correct 10 ms 9720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 11 ms 9724 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 10 ms 9720 KB Output is correct
5 Correct 10 ms 9720 KB Output is correct
6 Correct 11 ms 9720 KB Output is correct
7 Correct 10 ms 9720 KB Output is correct
8 Correct 10 ms 9720 KB Output is correct
9 Correct 11 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
11 Correct 13 ms 9848 KB Output is correct
12 Correct 15 ms 11364 KB Output is correct
13 Correct 15 ms 11364 KB Output is correct
14 Correct 12 ms 9720 KB Output is correct
15 Correct 13 ms 9720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 11 ms 9720 KB Output is correct
5 Correct 10 ms 9720 KB Output is correct
6 Correct 10 ms 9720 KB Output is correct
7 Correct 11 ms 9720 KB Output is correct
8 Correct 10 ms 9720 KB Output is correct
9 Correct 11 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
11 Correct 13 ms 9848 KB Output is correct
12 Correct 15 ms 11364 KB Output is correct
13 Correct 16 ms 11364 KB Output is correct
14 Correct 13 ms 9720 KB Output is correct
15 Correct 13 ms 9724 KB Output is correct
16 Correct 12 ms 9720 KB Output is correct
17 Correct 21 ms 9976 KB Output is correct
18 Correct 21 ms 9848 KB Output is correct
19 Correct 17 ms 9720 KB Output is correct
20 Correct 77 ms 41848 KB Output is correct
21 Correct 14 ms 9720 KB Output is correct
22 Correct 18 ms 9720 KB Output is correct
23 Correct 21 ms 9848 KB Output is correct
24 Correct 32 ms 9848 KB Output is correct
25 Correct 33 ms 9848 KB Output is correct
26 Correct 84 ms 41612 KB Output is correct
27 Correct 87 ms 41660 KB Output is correct
28 Correct 34 ms 9924 KB Output is correct
29 Correct 22 ms 10616 KB Output is correct
30 Correct 17 ms 9976 KB Output is correct
31 Correct 19 ms 10104 KB Output is correct
32 Correct 18 ms 9976 KB Output is correct
33 Correct 38 ms 11128 KB Output is correct
34 Correct 39 ms 11128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 11 ms 9720 KB Output is correct
3 Correct 11 ms 9720 KB Output is correct
4 Correct 11 ms 9720 KB Output is correct
5 Correct 10 ms 9720 KB Output is correct
6 Correct 10 ms 9720 KB Output is correct
7 Correct 12 ms 9720 KB Output is correct
8 Correct 11 ms 9724 KB Output is correct
9 Correct 12 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
11 Correct 13 ms 9848 KB Output is correct
12 Correct 15 ms 11364 KB Output is correct
13 Correct 16 ms 11364 KB Output is correct
14 Correct 13 ms 9720 KB Output is correct
15 Correct 14 ms 9976 KB Output is correct
16 Correct 12 ms 9720 KB Output is correct
17 Correct 20 ms 9976 KB Output is correct
18 Correct 21 ms 9848 KB Output is correct
19 Correct 17 ms 9720 KB Output is correct
20 Correct 77 ms 41848 KB Output is correct
21 Correct 13 ms 9720 KB Output is correct
22 Correct 18 ms 9848 KB Output is correct
23 Correct 20 ms 9852 KB Output is correct
24 Correct 32 ms 9976 KB Output is correct
25 Correct 34 ms 9848 KB Output is correct
26 Correct 87 ms 41660 KB Output is correct
27 Correct 84 ms 41532 KB Output is correct
28 Correct 35 ms 9976 KB Output is correct
29 Correct 22 ms 10616 KB Output is correct
30 Correct 14 ms 9976 KB Output is correct
31 Correct 19 ms 10104 KB Output is correct
32 Correct 18 ms 9972 KB Output is correct
33 Correct 39 ms 11128 KB Output is correct
34 Correct 38 ms 11128 KB Output is correct
35 Correct 232 ms 11768 KB Output is correct
36 Correct 43 ms 9976 KB Output is correct
37 Correct 236 ms 13152 KB Output is correct
38 Correct 360 ms 12664 KB Output is correct
39 Correct 369 ms 12792 KB Output is correct
40 Correct 363 ms 12664 KB Output is correct
41 Correct 364 ms 12536 KB Output is correct
42 Runtime error 398 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 10 ms 9720 KB Output is correct
5 Correct 10 ms 9716 KB Output is correct
6 Correct 10 ms 9720 KB Output is correct
7 Correct 10 ms 9720 KB Output is correct
8 Correct 11 ms 9720 KB Output is correct
9 Correct 10 ms 9724 KB Output is correct
10 Correct 11 ms 9724 KB Output is correct
11 Correct 13 ms 9848 KB Output is correct
12 Correct 16 ms 11504 KB Output is correct
13 Correct 15 ms 11364 KB Output is correct
14 Correct 13 ms 9720 KB Output is correct
15 Correct 13 ms 9720 KB Output is correct
16 Correct 12 ms 9720 KB Output is correct
17 Correct 19 ms 9976 KB Output is correct
18 Correct 21 ms 9720 KB Output is correct
19 Correct 17 ms 9720 KB Output is correct
20 Correct 79 ms 41848 KB Output is correct
21 Correct 14 ms 9720 KB Output is correct
22 Correct 18 ms 9720 KB Output is correct
23 Correct 21 ms 9844 KB Output is correct
24 Correct 32 ms 9848 KB Output is correct
25 Correct 34 ms 9976 KB Output is correct
26 Correct 88 ms 41788 KB Output is correct
27 Correct 82 ms 41532 KB Output is correct
28 Correct 36 ms 9976 KB Output is correct
29 Correct 21 ms 10488 KB Output is correct
30 Correct 13 ms 9976 KB Output is correct
31 Correct 19 ms 10104 KB Output is correct
32 Correct 18 ms 10104 KB Output is correct
33 Correct 39 ms 11128 KB Output is correct
34 Correct 39 ms 11128 KB Output is correct
35 Correct 230 ms 11512 KB Output is correct
36 Correct 43 ms 9972 KB Output is correct
37 Correct 239 ms 13160 KB Output is correct
38 Correct 362 ms 12684 KB Output is correct
39 Correct 365 ms 12920 KB Output is correct
40 Correct 362 ms 12664 KB Output is correct
41 Correct 364 ms 12536 KB Output is correct
42 Runtime error 377 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -