Submission #207092

# Submission time Handle Problem Language Result Execution time Memory
207092 2020-03-06T11:48:17 Z Sa1loum Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
497 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)1e6+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 19 ms 23800 KB Output is correct
2 Correct 19 ms 23804 KB Output is correct
3 Correct 19 ms 23804 KB Output is correct
4 Correct 19 ms 23800 KB Output is correct
5 Correct 19 ms 23800 KB Output is correct
6 Correct 19 ms 23800 KB Output is correct
7 Correct 20 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23800 KB Output is correct
2 Correct 20 ms 23800 KB Output is correct
3 Correct 22 ms 23800 KB Output is correct
4 Correct 20 ms 23800 KB Output is correct
5 Correct 20 ms 23800 KB Output is correct
6 Correct 19 ms 23800 KB Output is correct
7 Correct 20 ms 23800 KB Output is correct
8 Correct 19 ms 23800 KB Output is correct
9 Correct 19 ms 23800 KB Output is correct
10 Correct 20 ms 23928 KB Output is correct
11 Correct 20 ms 23928 KB Output is correct
12 Correct 24 ms 25960 KB Output is correct
13 Correct 24 ms 25964 KB Output is correct
14 Correct 20 ms 23928 KB Output is correct
15 Correct 19 ms 23928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 23800 KB Output is correct
2 Correct 20 ms 23800 KB Output is correct
3 Correct 19 ms 23800 KB Output is correct
4 Correct 19 ms 23800 KB Output is correct
5 Correct 20 ms 23800 KB Output is correct
6 Correct 20 ms 23800 KB Output is correct
7 Correct 19 ms 23800 KB Output is correct
8 Correct 20 ms 23800 KB Output is correct
9 Correct 19 ms 23800 KB Output is correct
10 Correct 20 ms 23800 KB Output is correct
11 Correct 20 ms 23928 KB Output is correct
12 Correct 24 ms 25964 KB Output is correct
13 Correct 27 ms 26092 KB Output is correct
14 Correct 21 ms 23928 KB Output is correct
15 Correct 20 ms 23928 KB Output is correct
16 Correct 19 ms 23928 KB Output is correct
17 Correct 21 ms 24312 KB Output is correct
18 Correct 20 ms 23928 KB Output is correct
19 Correct 20 ms 23928 KB Output is correct
20 Correct 496 ms 64240 KB Output is correct
21 Correct 20 ms 23800 KB Output is correct
22 Correct 20 ms 23928 KB Output is correct
23 Correct 22 ms 23928 KB Output is correct
24 Correct 21 ms 24056 KB Output is correct
25 Correct 22 ms 23928 KB Output is correct
26 Correct 89 ms 56892 KB Output is correct
27 Correct 87 ms 56892 KB Output is correct
28 Correct 20 ms 24056 KB Output is correct
29 Correct 29 ms 25204 KB Output is correct
30 Correct 22 ms 24312 KB Output is correct
31 Correct 24 ms 24568 KB Output is correct
32 Correct 21 ms 24312 KB Output is correct
33 Correct 45 ms 26352 KB Output is correct
34 Correct 36 ms 26224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 23804 KB Output is correct
2 Correct 19 ms 23800 KB Output is correct
3 Correct 19 ms 23804 KB Output is correct
4 Correct 20 ms 23800 KB Output is correct
5 Correct 20 ms 23800 KB Output is correct
6 Correct 20 ms 23800 KB Output is correct
7 Correct 20 ms 23800 KB Output is correct
8 Correct 20 ms 23800 KB Output is correct
9 Correct 19 ms 23800 KB Output is correct
10 Correct 19 ms 23928 KB Output is correct
11 Correct 19 ms 23928 KB Output is correct
12 Correct 24 ms 26092 KB Output is correct
13 Correct 25 ms 25968 KB Output is correct
14 Correct 21 ms 23928 KB Output is correct
15 Correct 21 ms 23928 KB Output is correct
16 Correct 20 ms 23928 KB Output is correct
17 Correct 22 ms 24312 KB Output is correct
18 Correct 20 ms 23928 KB Output is correct
19 Correct 19 ms 23928 KB Output is correct
20 Correct 497 ms 64368 KB Output is correct
21 Correct 19 ms 23804 KB Output is correct
22 Correct 20 ms 23928 KB Output is correct
23 Correct 20 ms 23928 KB Output is correct
24 Correct 21 ms 24056 KB Output is correct
25 Correct 22 ms 23928 KB Output is correct
26 Correct 88 ms 56892 KB Output is correct
27 Correct 88 ms 56892 KB Output is correct
28 Correct 21 ms 24056 KB Output is correct
29 Correct 29 ms 25204 KB Output is correct
30 Correct 22 ms 24312 KB Output is correct
31 Correct 24 ms 24568 KB Output is correct
32 Correct 22 ms 24312 KB Output is correct
33 Correct 42 ms 26224 KB Output is correct
34 Correct 35 ms 26220 KB Output is correct
35 Correct 32 ms 26240 KB Output is correct
36 Correct 21 ms 24056 KB Output is correct
37 Correct 34 ms 28272 KB Output is correct
38 Correct 38 ms 27772 KB Output is correct
39 Correct 34 ms 26748 KB Output is correct
40 Correct 34 ms 27000 KB Output is correct
41 Correct 39 ms 27764 KB Output is correct
42 Runtime error 400 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 20 ms 23800 KB Output is correct
2 Correct 19 ms 23800 KB Output is correct
3 Correct 20 ms 23800 KB Output is correct
4 Correct 19 ms 23800 KB Output is correct
5 Correct 20 ms 23804 KB Output is correct
6 Correct 19 ms 23800 KB Output is correct
7 Correct 19 ms 23800 KB Output is correct
8 Correct 19 ms 23800 KB Output is correct
9 Correct 19 ms 23800 KB Output is correct
10 Correct 20 ms 23800 KB Output is correct
11 Correct 20 ms 23928 KB Output is correct
12 Correct 23 ms 26092 KB Output is correct
13 Correct 25 ms 26092 KB Output is correct
14 Correct 20 ms 23928 KB Output is correct
15 Correct 20 ms 23928 KB Output is correct
16 Correct 20 ms 23932 KB Output is correct
17 Correct 21 ms 24312 KB Output is correct
18 Correct 21 ms 23928 KB Output is correct
19 Correct 20 ms 23928 KB Output is correct
20 Correct 497 ms 64436 KB Output is correct
21 Correct 20 ms 23800 KB Output is correct
22 Correct 19 ms 23928 KB Output is correct
23 Correct 22 ms 23928 KB Output is correct
24 Correct 21 ms 24056 KB Output is correct
25 Correct 21 ms 24056 KB Output is correct
26 Correct 90 ms 56900 KB Output is correct
27 Correct 86 ms 56892 KB Output is correct
28 Correct 21 ms 24056 KB Output is correct
29 Correct 30 ms 25200 KB Output is correct
30 Correct 22 ms 24312 KB Output is correct
31 Correct 25 ms 24568 KB Output is correct
32 Correct 22 ms 24312 KB Output is correct
33 Correct 42 ms 26352 KB Output is correct
34 Correct 33 ms 26224 KB Output is correct
35 Correct 32 ms 26240 KB Output is correct
36 Correct 21 ms 24056 KB Output is correct
37 Correct 34 ms 28268 KB Output is correct
38 Correct 38 ms 27768 KB Output is correct
39 Correct 33 ms 26744 KB Output is correct
40 Correct 34 ms 27000 KB Output is correct
41 Correct 37 ms 27636 KB Output is correct
42 Runtime error 396 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -