Submission #452089

# Submission time Handle Problem Language Result Execution time Memory
452089 2021-08-03T18:36:01 Z Sarah_Mokhtar Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
546 ms 262148 KB
//Sorry but iam targeting IOI :))
//NEVER LOSE HOPE
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define endl "\n"
#define ceil(a,b)   (a+(b-1))/b
#define all(v) v.begin(),v.end()
#define Hidden ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int mod = 1e9+7;
int32_t main()
{
    Hidden;
    pair<int,int>arr[30005];
    vector<pair<int,int>>edges[30005];
    vector<int>freq[30005];
    int n, m;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i ++)
    {
        int b , p;
        cin>>b>>p;
        arr[i]={b,p};
        freq[b].push_back(i);
    }
    for(int i = 0 ; i < m ; i++)
    {
        for(int j = arr[i].first+arr[i].second ; j<=n ; j+=arr[i].second)
        {
        for(int p = 0 ; p < freq[j].size() ; p ++)
        {
            edges[arr[i].first].push_back({arr[freq[j][p]].first ,(j-arr[i].first)/arr[i].second});
        }
        }
        for(int j = arr[i].first-arr[i].second ; j>=0 ; j-=arr[i].second)
        {
        for(int p = 0 ; p < freq[j].size() ; p ++)
        {
            edges[arr[i].first].push_back({arr[freq[j][p]].first ,(arr[i].first-j)/arr[i].second});
        }
        }
    }
    
    
    priority_queue<pair<int,int>>pq;
    pq.push({0,arr[0].first});
    int dist[30005];
    for(int i = 0 ; i < 30005 ; i++) dist[i]=INT_MAX;
    dist[arr[0].first]=0;
    while(!pq.empty())
    {
        pair<int,int>p=pq.top();
        pq.pop();
        for(int i = 0; i < edges[p.second].size() ; i++)
        {
        int cost=dist[p.second]+edges[p.second][i].second;
        if(dist[edges[p.second][i].first] > cost||dist[edges[p.second][i].first]==INT_MAX)
        {
            dist[edges[p.second][i].first] = cost;
            pq.push({-cost , edges[p.second][i].first});
        }
        }
    }
    if(dist[arr[1].first] == INT_MAX) cout<<"-1";
    else cout<<dist[arr[1].first];
}

Compilation message

skyscraper.cpp: In function 'int32_t main()':
skyscraper.cpp:31:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int p = 0 ; p < freq[j].size() ; p ++)
      |                         ~~^~~~~~~~~~~~~~~~
skyscraper.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int p = 0 ; p < freq[j].size() ; p ++)
      |                         ~~^~~~~~~~~~~~~~~~
skyscraper.cpp:55:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i = 0; i < edges[p.second].size() ; i++)
      |                        ~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1996 KB Output is correct
2 Correct 1 ms 1996 KB Output is correct
3 Correct 1 ms 1996 KB Output is correct
4 Correct 1 ms 1996 KB Output is correct
5 Correct 2 ms 1948 KB Output is correct
6 Correct 2 ms 1996 KB Output is correct
7 Correct 1 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1996 KB Output is correct
2 Correct 2 ms 1996 KB Output is correct
3 Correct 1 ms 1996 KB Output is correct
4 Correct 1 ms 1996 KB Output is correct
5 Correct 1 ms 1996 KB Output is correct
6 Correct 1 ms 2052 KB Output is correct
7 Correct 1 ms 1996 KB Output is correct
8 Correct 1 ms 1996 KB Output is correct
9 Correct 1 ms 1996 KB Output is correct
10 Correct 2 ms 2124 KB Output is correct
11 Correct 5 ms 3788 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 9 ms 5324 KB Output is correct
14 Correct 3 ms 2508 KB Output is correct
15 Correct 3 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1996 KB Output is correct
2 Correct 2 ms 1996 KB Output is correct
3 Correct 1 ms 1996 KB Output is correct
4 Correct 1 ms 1996 KB Output is correct
5 Correct 1 ms 1996 KB Output is correct
6 Correct 2 ms 1996 KB Output is correct
7 Correct 1 ms 1996 KB Output is correct
8 Correct 1 ms 1996 KB Output is correct
9 Correct 2 ms 1996 KB Output is correct
10 Correct 2 ms 2124 KB Output is correct
11 Correct 5 ms 3852 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 9 ms 5312 KB Output is correct
14 Correct 3 ms 2508 KB Output is correct
15 Correct 3 ms 2476 KB Output is correct
16 Correct 2 ms 2380 KB Output is correct
17 Correct 3 ms 2636 KB Output is correct
18 Correct 2 ms 2124 KB Output is correct
19 Correct 2 ms 1996 KB Output is correct
20 Correct 69 ms 34136 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 2 ms 1996 KB Output is correct
23 Correct 2 ms 2124 KB Output is correct
24 Correct 4 ms 2252 KB Output is correct
25 Correct 3 ms 2124 KB Output is correct
26 Correct 20 ms 6332 KB Output is correct
27 Correct 15 ms 4240 KB Output is correct
28 Correct 3 ms 2252 KB Output is correct
29 Correct 2 ms 2124 KB Output is correct
30 Correct 1 ms 1996 KB Output is correct
31 Correct 2 ms 1996 KB Output is correct
32 Correct 2 ms 2084 KB Output is correct
33 Correct 3 ms 2508 KB Output is correct
34 Correct 3 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1996 KB Output is correct
2 Correct 1 ms 1996 KB Output is correct
3 Correct 1 ms 1996 KB Output is correct
4 Correct 1 ms 1996 KB Output is correct
5 Correct 1 ms 1996 KB Output is correct
6 Correct 1 ms 1996 KB Output is correct
7 Correct 1 ms 1996 KB Output is correct
8 Correct 2 ms 1996 KB Output is correct
9 Correct 1 ms 1996 KB Output is correct
10 Correct 2 ms 2124 KB Output is correct
11 Correct 5 ms 3788 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 10 ms 5312 KB Output is correct
14 Correct 3 ms 2508 KB Output is correct
15 Correct 3 ms 2508 KB Output is correct
16 Correct 2 ms 2252 KB Output is correct
17 Correct 3 ms 2636 KB Output is correct
18 Correct 2 ms 2124 KB Output is correct
19 Correct 2 ms 1996 KB Output is correct
20 Correct 70 ms 34176 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 2 ms 1996 KB Output is correct
23 Correct 2 ms 2124 KB Output is correct
24 Correct 4 ms 2252 KB Output is correct
25 Correct 2 ms 2124 KB Output is correct
26 Correct 18 ms 6324 KB Output is correct
27 Correct 18 ms 4208 KB Output is correct
28 Correct 2 ms 2252 KB Output is correct
29 Correct 2 ms 2124 KB Output is correct
30 Correct 1 ms 1996 KB Output is correct
31 Correct 2 ms 1996 KB Output is correct
32 Correct 2 ms 1996 KB Output is correct
33 Correct 3 ms 2508 KB Output is correct
34 Correct 3 ms 2508 KB Output is correct
35 Correct 58 ms 25940 KB Output is correct
36 Correct 5 ms 2892 KB Output is correct
37 Correct 68 ms 31028 KB Output is correct
38 Correct 78 ms 35132 KB Output is correct
39 Correct 81 ms 37732 KB Output is correct
40 Correct 80 ms 35792 KB Output is correct
41 Correct 79 ms 34136 KB Output is correct
42 Correct 273 ms 68520 KB Output is correct
43 Correct 228 ms 35408 KB Output is correct
44 Runtime error 518 ms 262148 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1996 KB Output is correct
2 Correct 1 ms 1996 KB Output is correct
3 Correct 3 ms 1996 KB Output is correct
4 Correct 1 ms 1996 KB Output is correct
5 Correct 1 ms 1996 KB Output is correct
6 Correct 1 ms 1996 KB Output is correct
7 Correct 1 ms 1996 KB Output is correct
8 Correct 1 ms 1996 KB Output is correct
9 Correct 1 ms 1996 KB Output is correct
10 Correct 2 ms 2124 KB Output is correct
11 Correct 5 ms 3788 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 9 ms 5312 KB Output is correct
14 Correct 3 ms 2508 KB Output is correct
15 Correct 3 ms 2460 KB Output is correct
16 Correct 2 ms 2252 KB Output is correct
17 Correct 3 ms 2636 KB Output is correct
18 Correct 2 ms 2124 KB Output is correct
19 Correct 2 ms 1996 KB Output is correct
20 Correct 69 ms 34184 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 2 ms 1996 KB Output is correct
23 Correct 2 ms 2124 KB Output is correct
24 Correct 4 ms 2252 KB Output is correct
25 Correct 3 ms 2124 KB Output is correct
26 Correct 18 ms 6332 KB Output is correct
27 Correct 15 ms 4308 KB Output is correct
28 Correct 3 ms 2252 KB Output is correct
29 Correct 2 ms 2124 KB Output is correct
30 Correct 2 ms 1996 KB Output is correct
31 Correct 2 ms 1996 KB Output is correct
32 Correct 2 ms 1996 KB Output is correct
33 Correct 3 ms 2508 KB Output is correct
34 Correct 3 ms 2508 KB Output is correct
35 Correct 65 ms 25956 KB Output is correct
36 Correct 5 ms 2892 KB Output is correct
37 Correct 69 ms 30984 KB Output is correct
38 Correct 87 ms 35096 KB Output is correct
39 Correct 84 ms 37684 KB Output is correct
40 Correct 82 ms 35728 KB Output is correct
41 Correct 76 ms 34028 KB Output is correct
42 Correct 278 ms 68572 KB Output is correct
43 Correct 235 ms 35404 KB Output is correct
44 Runtime error 546 ms 262148 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -