Submission #207097

# Submission time Handle Problem Language Result Execution time Memory
207097 2020-03-06T12:21:17 Z Sa1loum Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
487 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define F first
#define S second
#define Si size()
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)3e4+10;
int n,m,b[MAX],p[MAX],vis[MAX];
vector <pair<int,int> > v[MAX];
int main()
{
    scanf("%d%d",&n,&m);
    int s,e;
    for (int i=0;i<m;i++) {
        scanf("%d%d",&b[i],&p[i]);
        int d=0;
        if (i==0) s=b[i];
        if (i==1) e=b[i];
        for (int j=b[i],k=b[i];;j+=p[i],k-=p[i]) {
            bool flag=0;
            if (0<=j && j<n) {
                flag=1;
                if (j!=b[i]) {
                    v[b[i]].push_back({j,d});
                }
            }
            if (0<=k && k<n) {
                flag=1;
                if (k!=b[i]) {
                    v[b[i]].push_back({k,d});
                }
            }
            d++;
            if (!flag) break;
        }
    }
    priority_queue <pair<int,int>> pq;
    pq.push({0,s});
    while (!pq.empty()) {
        int x=pq.top().S;
        int w=-pq.top().F;
        pq.pop();
        if (vis[x]) continue;
        vis[x]=1;
        if (x==e) {printf("%d\n",w); return 0;}
        for (auto it:v[x]) {
            if (vis[it.F]) continue;
            pq.push({-w-it.S,it.F});
        }
    }
    puts("-1\n");
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&b[i],&p[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:50:9: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (x==e) {printf("%d\n",w); return 0;}
         ^~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1016 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Correct 5 ms 1016 KB Output is correct
4 Correct 5 ms 1016 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1020 KB Output is correct
2 Correct 6 ms 1016 KB Output is correct
3 Correct 5 ms 1016 KB Output is correct
4 Correct 5 ms 1016 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 1016 KB Output is correct
8 Correct 5 ms 1016 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 1016 KB Output is correct
11 Correct 6 ms 1144 KB Output is correct
12 Correct 9 ms 3308 KB Output is correct
13 Correct 11 ms 3348 KB Output is correct
14 Correct 6 ms 1144 KB Output is correct
15 Correct 6 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1016 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Correct 5 ms 1016 KB Output is correct
4 Correct 5 ms 1016 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 1016 KB Output is correct
8 Correct 5 ms 1016 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 1144 KB Output is correct
11 Correct 6 ms 1144 KB Output is correct
12 Correct 9 ms 3176 KB Output is correct
13 Correct 10 ms 3180 KB Output is correct
14 Correct 6 ms 1144 KB Output is correct
15 Correct 6 ms 1144 KB Output is correct
16 Correct 5 ms 1144 KB Output is correct
17 Correct 7 ms 1528 KB Output is correct
18 Correct 6 ms 1272 KB Output is correct
19 Correct 6 ms 1144 KB Output is correct
20 Correct 487 ms 41456 KB Output is correct
21 Correct 5 ms 1016 KB Output is correct
22 Correct 6 ms 1144 KB Output is correct
23 Correct 6 ms 1144 KB Output is correct
24 Correct 7 ms 1276 KB Output is correct
25 Correct 6 ms 1144 KB Output is correct
26 Correct 94 ms 34108 KB Output is correct
27 Correct 72 ms 33980 KB Output is correct
28 Correct 6 ms 1272 KB Output is correct
29 Correct 18 ms 2420 KB Output is correct
30 Correct 8 ms 1528 KB Output is correct
31 Correct 10 ms 1784 KB Output is correct
32 Correct 8 ms 1528 KB Output is correct
33 Correct 27 ms 3440 KB Output is correct
34 Correct 20 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1016 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Correct 5 ms 1016 KB Output is correct
4 Correct 5 ms 1016 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 1016 KB Output is correct
8 Correct 5 ms 1016 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 1144 KB Output is correct
11 Correct 6 ms 1144 KB Output is correct
12 Correct 9 ms 3176 KB Output is correct
13 Correct 10 ms 3180 KB Output is correct
14 Correct 6 ms 1144 KB Output is correct
15 Correct 6 ms 1144 KB Output is correct
16 Correct 5 ms 1144 KB Output is correct
17 Correct 7 ms 1468 KB Output is correct
18 Correct 6 ms 1144 KB Output is correct
19 Correct 5 ms 1020 KB Output is correct
20 Correct 478 ms 41460 KB Output is correct
21 Correct 6 ms 1016 KB Output is correct
22 Correct 5 ms 1144 KB Output is correct
23 Correct 6 ms 1144 KB Output is correct
24 Correct 7 ms 1272 KB Output is correct
25 Correct 6 ms 1144 KB Output is correct
26 Correct 75 ms 34108 KB Output is correct
27 Correct 72 ms 33980 KB Output is correct
28 Correct 6 ms 1272 KB Output is correct
29 Correct 16 ms 2420 KB Output is correct
30 Correct 8 ms 1532 KB Output is correct
31 Correct 9 ms 1784 KB Output is correct
32 Correct 8 ms 1528 KB Output is correct
33 Correct 27 ms 3436 KB Output is correct
34 Correct 20 ms 3440 KB Output is correct
35 Correct 18 ms 3456 KB Output is correct
36 Correct 7 ms 1272 KB Output is correct
37 Correct 19 ms 5488 KB Output is correct
38 Correct 23 ms 4860 KB Output is correct
39 Correct 19 ms 3960 KB Output is correct
40 Correct 19 ms 4216 KB Output is correct
41 Correct 22 ms 4852 KB Output is correct
42 Runtime error 397 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 5 ms 1016 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Correct 5 ms 1016 KB Output is correct
4 Correct 5 ms 1020 KB Output is correct
5 Correct 5 ms 1016 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 1016 KB Output is correct
8 Correct 5 ms 1016 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 6 ms 1016 KB Output is correct
11 Correct 6 ms 1144 KB Output is correct
12 Correct 9 ms 3180 KB Output is correct
13 Correct 10 ms 3308 KB Output is correct
14 Correct 6 ms 1144 KB Output is correct
15 Correct 6 ms 1144 KB Output is correct
16 Correct 5 ms 1144 KB Output is correct
17 Correct 7 ms 1468 KB Output is correct
18 Correct 6 ms 1144 KB Output is correct
19 Correct 5 ms 1016 KB Output is correct
20 Correct 475 ms 41460 KB Output is correct
21 Correct 6 ms 1016 KB Output is correct
22 Correct 5 ms 1144 KB Output is correct
23 Correct 6 ms 1144 KB Output is correct
24 Correct 7 ms 1272 KB Output is correct
25 Correct 6 ms 1144 KB Output is correct
26 Correct 74 ms 34108 KB Output is correct
27 Correct 72 ms 33980 KB Output is correct
28 Correct 6 ms 1272 KB Output is correct
29 Correct 18 ms 2548 KB Output is correct
30 Correct 7 ms 1528 KB Output is correct
31 Correct 9 ms 1784 KB Output is correct
32 Correct 8 ms 1528 KB Output is correct
33 Correct 28 ms 3436 KB Output is correct
34 Correct 20 ms 3440 KB Output is correct
35 Correct 18 ms 3456 KB Output is correct
36 Correct 7 ms 1272 KB Output is correct
37 Correct 20 ms 5488 KB Output is correct
38 Correct 25 ms 4988 KB Output is correct
39 Correct 19 ms 4012 KB Output is correct
40 Correct 19 ms 4216 KB Output is correct
41 Correct 23 ms 4852 KB Output is correct
42 Runtime error 401 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -