Submission #1110701

# Submission time Handle Problem Language Result Execution time Memory
1110701 2024-11-10T08:24:26 Z malacia Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
603 ms 5324 KB
#include<bits/stdc++.h>
#define fo(i,x,n) for(int i=x;i<=n;++i)
#define fi(i,x,n) for(int i=x;i>=n;--i)
#define SYNCHRONIZE ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define BIT(i,mask) ((mask >> (i-1)) & 1)
#define pli pair<ll,int>
#define maxn 50005
#define pll pair<ll,ll>
#define uni(vt) vt.resize(unique(vt.begin(),vt.end()) - vt.begin());
#define DAOBIT(i,mask) ((mask ^ (1ll<<i-1)))
#define OFFBIT(i,mask) ((mask & ~(1ll << (i - 1))))
#define ONBIT(i,mask) ((mask  (1ll << (i - 1))))
const int oo =1e9+7;
using namespace std;
//----------------- STRUCTURE ---------------
struct node {
      int pos , power, dp;
};

struct cmp {
      bool operator() (node &A ,node &B) {
            return A.dp > B.dp;
      }
};
//----------------- DECLARE ------------------
int n, m ,dp[maxn] , hs, bf[maxn];
pii dogs[maxn];
vector<int> vt[maxn];
priority_queue<pii,vector<pii>,greater<pii> > pq;
//----------------- FUNCTION -----------------

//----------------- MAIN PRO ------------------
int main()
{
    SYNCHRONIZE;

    cin >>n >>m;

    fo(i,0,m-1) {
          cin >> dogs[i].first >> dogs[i].second ;
          vt[dogs[i].first].push_back(dogs[i].second);
    }

    fo(i,0,n-1) dp[i] = oo;
    dp[dogs[0].first] = 0;
    pq.push({0,dogs[0].first});

    while(pq.size() > 0) {
       auto [num,u] = pq.top();
       pq.pop();

       if(dp[u] != num) continue;

       for(auto power : vt[u]) {
            for(int v = 1 ; u+v*power < n ; v++) if(dp[u+v*power] > dp[u]+v) {
                  dp[u+v*power] = dp[u] + v;
                  pq.push({dp[u]+v,u+v*power});
            }

            for(int v = 1 ; u-v*power >= 0; ++v) if(dp[u-v*power] > dp[u] + v) {
                  pq.push({dp[u]+v,u-v*power});
                  dp[u-v*power] = dp[u] + v;
            }
       }
    }

    cout << (dp[dogs[1].first] == oo ? -1 : dp[dogs[1].first]) ;

}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:53:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   53 |        auto [num,u] = pq.top();
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 2 ms 1616 KB Output is correct
3 Correct 2 ms 1616 KB Output is correct
4 Correct 2 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 2 ms 1788 KB Output is correct
7 Correct 2 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 2 ms 1616 KB Output is correct
3 Correct 2 ms 1616 KB Output is correct
4 Correct 2 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1616 KB Output is correct
11 Correct 2 ms 1616 KB Output is correct
12 Correct 2 ms 1616 KB Output is correct
13 Correct 2 ms 1616 KB Output is correct
14 Correct 2 ms 1616 KB Output is correct
15 Correct 2 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 2 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 2 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 2 ms 1572 KB Output is correct
9 Correct 1 ms 1788 KB Output is correct
10 Correct 2 ms 1412 KB Output is correct
11 Correct 2 ms 1616 KB Output is correct
12 Correct 2 ms 1616 KB Output is correct
13 Correct 2 ms 1616 KB Output is correct
14 Correct 2 ms 1616 KB Output is correct
15 Correct 2 ms 1600 KB Output is correct
16 Correct 2 ms 1616 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 2 ms 1616 KB Output is correct
19 Correct 2 ms 1616 KB Output is correct
20 Correct 4 ms 1616 KB Output is correct
21 Correct 2 ms 1616 KB Output is correct
22 Correct 2 ms 1616 KB Output is correct
23 Correct 2 ms 1616 KB Output is correct
24 Correct 2 ms 1616 KB Output is correct
25 Correct 2 ms 1616 KB Output is correct
26 Correct 4 ms 1616 KB Output is correct
27 Correct 4 ms 1616 KB Output is correct
28 Correct 2 ms 1616 KB Output is correct
29 Correct 2 ms 1872 KB Output is correct
30 Correct 3 ms 1616 KB Output is correct
31 Correct 2 ms 1616 KB Output is correct
32 Correct 2 ms 1616 KB Output is correct
33 Correct 4 ms 1716 KB Output is correct
34 Correct 3 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 2 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 2 ms 1784 KB Output is correct
8 Correct 2 ms 1616 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1616 KB Output is correct
11 Correct 2 ms 1616 KB Output is correct
12 Correct 2 ms 1616 KB Output is correct
13 Correct 2 ms 1616 KB Output is correct
14 Correct 2 ms 1616 KB Output is correct
15 Correct 2 ms 1616 KB Output is correct
16 Correct 2 ms 1616 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 2 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 5 ms 1784 KB Output is correct
21 Correct 2 ms 1616 KB Output is correct
22 Correct 1 ms 1616 KB Output is correct
23 Correct 2 ms 1616 KB Output is correct
24 Correct 2 ms 1616 KB Output is correct
25 Correct 2 ms 1616 KB Output is correct
26 Correct 3 ms 1616 KB Output is correct
27 Correct 4 ms 1784 KB Output is correct
28 Correct 2 ms 1616 KB Output is correct
29 Correct 3 ms 1872 KB Output is correct
30 Correct 2 ms 1616 KB Output is correct
31 Correct 2 ms 1616 KB Output is correct
32 Correct 2 ms 1616 KB Output is correct
33 Correct 3 ms 1872 KB Output is correct
34 Correct 3 ms 1920 KB Output is correct
35 Correct 5 ms 2300 KB Output is correct
36 Correct 2 ms 1628 KB Output is correct
37 Correct 6 ms 2104 KB Output is correct
38 Correct 6 ms 2128 KB Output is correct
39 Correct 6 ms 2128 KB Output is correct
40 Correct 6 ms 2128 KB Output is correct
41 Correct 6 ms 2140 KB Output is correct
42 Correct 35 ms 2128 KB Output is correct
43 Correct 43 ms 2128 KB Output is correct
44 Correct 36 ms 2300 KB Output is correct
45 Correct 6 ms 2128 KB Output is correct
46 Correct 9 ms 2228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1788 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 1 ms 1612 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 2 ms 1616 KB Output is correct
11 Correct 2 ms 1616 KB Output is correct
12 Correct 2 ms 1788 KB Output is correct
13 Correct 2 ms 1616 KB Output is correct
14 Correct 2 ms 1784 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 1 ms 1616 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 2 ms 1616 KB Output is correct
19 Correct 2 ms 1616 KB Output is correct
20 Correct 4 ms 1616 KB Output is correct
21 Correct 2 ms 1660 KB Output is correct
22 Correct 2 ms 1616 KB Output is correct
23 Correct 2 ms 1616 KB Output is correct
24 Correct 2 ms 1616 KB Output is correct
25 Correct 2 ms 1768 KB Output is correct
26 Correct 4 ms 1616 KB Output is correct
27 Correct 4 ms 1616 KB Output is correct
28 Correct 2 ms 1784 KB Output is correct
29 Correct 3 ms 1872 KB Output is correct
30 Correct 2 ms 1784 KB Output is correct
31 Correct 3 ms 1616 KB Output is correct
32 Correct 2 ms 1800 KB Output is correct
33 Correct 3 ms 1872 KB Output is correct
34 Correct 3 ms 1872 KB Output is correct
35 Correct 5 ms 2128 KB Output is correct
36 Correct 3 ms 1616 KB Output is correct
37 Correct 5 ms 1872 KB Output is correct
38 Correct 7 ms 2128 KB Output is correct
39 Correct 6 ms 2064 KB Output is correct
40 Correct 7 ms 2140 KB Output is correct
41 Correct 6 ms 2128 KB Output is correct
42 Correct 36 ms 2128 KB Output is correct
43 Correct 37 ms 2128 KB Output is correct
44 Correct 35 ms 2296 KB Output is correct
45 Correct 6 ms 2128 KB Output is correct
46 Correct 6 ms 2056 KB Output is correct
47 Correct 13 ms 2764 KB Output is correct
48 Correct 6 ms 2128 KB Output is correct
49 Correct 5 ms 2128 KB Output is correct
50 Correct 4 ms 2128 KB Output is correct
51 Correct 20 ms 3504 KB Output is correct
52 Correct 20 ms 3020 KB Output is correct
53 Correct 13 ms 3020 KB Output is correct
54 Correct 3 ms 1872 KB Output is correct
55 Correct 5 ms 1872 KB Output is correct
56 Correct 567 ms 3212 KB Output is correct
57 Correct 34 ms 5060 KB Output is correct
58 Correct 603 ms 2128 KB Output is correct
59 Correct 464 ms 2128 KB Output is correct
60 Correct 594 ms 2264 KB Output is correct
61 Correct 433 ms 2128 KB Output is correct
62 Correct 8 ms 2896 KB Output is correct
63 Correct 24 ms 3380 KB Output is correct
64 Correct 23 ms 5316 KB Output is correct
65 Correct 29 ms 5324 KB Output is correct
66 Correct 41 ms 5316 KB Output is correct
67 Correct 43 ms 5316 KB Output is correct