Submission #60624

# Submission time Handle Problem Language Result Execution time Memory
60624 2018-07-24T11:53:17 Z Flugan42 Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 6884 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define inf 9223372036854775807
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto& a : x)

ll n,m;
vi b,p,vis,_,mindist;
vector<vi> dog;
vector<set<ll> > jumps;
set<ll> __;

int main(){
  cin >> n >> m; b.assign(m,0); p.assign(m,0);
  jumps.assign(n,__);
  rep(i,0,m) {
    cin >> b[i] >> p[i];
    jumps[b[i]].insert(p[i]);
  }
  dog.assign(n,_);
  rep(i,0,m) dog[b[i]].push_back(i);
  vis.assign(n,0);
  priority_queue<ii> pq;
  pq.push(make_pair(0,b[0]));
  mindist.assign(n,inf);

  while (!pq.empty()){
    ll dist = -pq.top().first, i = pq.top().second; pq.pop();
    if (i == b[1]) {
      cout << dist << endl;
      exit(0);
    }
    if (vis[i]) continue;
    vis[i] = 1;
    trav(px,jumps[i]){
      ll cur = i+px,cnt = 1;
      while (cur < n) {
        if (!vis[cur] && mindist[cur] > dist+cnt && sz(dog[cur]) > 0) {
          pq.push(make_pair(-dist-cnt,cur));
          mindist[cur] = dist+cnt;
        }
        cur += px; cnt++;
      }
      cur = i-px, cnt = 1;
      while (cur >= 0){
        if (!vis[cur] && mindist[cur] > dist+cnt && sz(dog[cur]) > 0) {
          pq.push(make_pair(-dist-cnt,cur));
          mindist[cur] = dist+cnt;
        }
        cur -= px; cnt++;
      }
    }
  }
  cout << -1 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 524 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 2 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 580 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 3 ms 620 KB Output is correct
10 Correct 4 ms 620 KB Output is correct
11 Correct 4 ms 836 KB Output is correct
12 Correct 4 ms 836 KB Output is correct
13 Correct 4 ms 836 KB Output is correct
14 Correct 4 ms 836 KB Output is correct
15 Correct 6 ms 836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 836 KB Output is correct
2 Correct 2 ms 836 KB Output is correct
3 Correct 2 ms 836 KB Output is correct
4 Correct 3 ms 836 KB Output is correct
5 Correct 3 ms 836 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
8 Correct 2 ms 836 KB Output is correct
9 Correct 2 ms 836 KB Output is correct
10 Correct 3 ms 836 KB Output is correct
11 Correct 6 ms 836 KB Output is correct
12 Correct 4 ms 836 KB Output is correct
13 Correct 4 ms 836 KB Output is correct
14 Correct 5 ms 836 KB Output is correct
15 Correct 3 ms 836 KB Output is correct
16 Correct 3 ms 836 KB Output is correct
17 Correct 4 ms 836 KB Output is correct
18 Correct 3 ms 836 KB Output is correct
19 Correct 3 ms 836 KB Output is correct
20 Correct 16 ms 920 KB Output is correct
21 Correct 5 ms 920 KB Output is correct
22 Correct 4 ms 920 KB Output is correct
23 Correct 4 ms 920 KB Output is correct
24 Correct 5 ms 920 KB Output is correct
25 Correct 4 ms 920 KB Output is correct
26 Correct 5 ms 920 KB Output is correct
27 Correct 5 ms 920 KB Output is correct
28 Correct 6 ms 920 KB Output is correct
29 Correct 4 ms 920 KB Output is correct
30 Correct 3 ms 920 KB Output is correct
31 Correct 4 ms 920 KB Output is correct
32 Correct 4 ms 920 KB Output is correct
33 Correct 5 ms 920 KB Output is correct
34 Correct 6 ms 920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 920 KB Output is correct
2 Correct 3 ms 920 KB Output is correct
3 Correct 3 ms 920 KB Output is correct
4 Correct 3 ms 920 KB Output is correct
5 Correct 2 ms 920 KB Output is correct
6 Correct 2 ms 920 KB Output is correct
7 Correct 2 ms 920 KB Output is correct
8 Correct 3 ms 920 KB Output is correct
9 Correct 3 ms 920 KB Output is correct
10 Correct 3 ms 920 KB Output is correct
11 Correct 6 ms 920 KB Output is correct
12 Correct 4 ms 920 KB Output is correct
13 Correct 4 ms 920 KB Output is correct
14 Correct 5 ms 920 KB Output is correct
15 Correct 5 ms 920 KB Output is correct
16 Correct 4 ms 920 KB Output is correct
17 Correct 6 ms 920 KB Output is correct
18 Correct 4 ms 920 KB Output is correct
19 Correct 4 ms 920 KB Output is correct
20 Correct 13 ms 1004 KB Output is correct
21 Correct 3 ms 1004 KB Output is correct
22 Correct 3 ms 1004 KB Output is correct
23 Correct 4 ms 1004 KB Output is correct
24 Correct 5 ms 1004 KB Output is correct
25 Correct 6 ms 1004 KB Output is correct
26 Correct 4 ms 1004 KB Output is correct
27 Correct 4 ms 1004 KB Output is correct
28 Correct 5 ms 1004 KB Output is correct
29 Correct 4 ms 1004 KB Output is correct
30 Correct 3 ms 1004 KB Output is correct
31 Correct 3 ms 1004 KB Output is correct
32 Correct 3 ms 1004 KB Output is correct
33 Correct 5 ms 1004 KB Output is correct
34 Correct 5 ms 1004 KB Output is correct
35 Correct 35 ms 2848 KB Output is correct
36 Correct 9 ms 2848 KB Output is correct
37 Correct 27 ms 2848 KB Output is correct
38 Correct 59 ms 3308 KB Output is correct
39 Correct 36 ms 3308 KB Output is correct
40 Correct 53 ms 3308 KB Output is correct
41 Correct 59 ms 3348 KB Output is correct
42 Correct 25 ms 3348 KB Output is correct
43 Correct 32 ms 3348 KB Output is correct
44 Correct 42 ms 3348 KB Output is correct
45 Correct 41 ms 3348 KB Output is correct
46 Correct 43 ms 3348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3348 KB Output is correct
2 Correct 3 ms 3348 KB Output is correct
3 Correct 3 ms 3348 KB Output is correct
4 Correct 3 ms 3348 KB Output is correct
5 Correct 2 ms 3348 KB Output is correct
6 Correct 3 ms 3348 KB Output is correct
7 Correct 2 ms 3348 KB Output is correct
8 Correct 2 ms 3348 KB Output is correct
9 Correct 3 ms 3348 KB Output is correct
10 Correct 4 ms 3348 KB Output is correct
11 Correct 4 ms 3348 KB Output is correct
12 Correct 4 ms 3348 KB Output is correct
13 Correct 5 ms 3348 KB Output is correct
14 Correct 6 ms 3348 KB Output is correct
15 Correct 7 ms 3348 KB Output is correct
16 Correct 3 ms 3348 KB Output is correct
17 Correct 5 ms 3348 KB Output is correct
18 Correct 4 ms 3348 KB Output is correct
19 Correct 4 ms 3348 KB Output is correct
20 Correct 12 ms 3348 KB Output is correct
21 Correct 5 ms 3348 KB Output is correct
22 Correct 4 ms 3348 KB Output is correct
23 Correct 4 ms 3348 KB Output is correct
24 Correct 6 ms 3348 KB Output is correct
25 Correct 7 ms 3348 KB Output is correct
26 Correct 5 ms 3348 KB Output is correct
27 Correct 5 ms 3348 KB Output is correct
28 Correct 6 ms 3348 KB Output is correct
29 Correct 5 ms 3348 KB Output is correct
30 Correct 3 ms 3348 KB Output is correct
31 Correct 4 ms 3348 KB Output is correct
32 Correct 4 ms 3348 KB Output is correct
33 Correct 6 ms 3348 KB Output is correct
34 Correct 5 ms 3348 KB Output is correct
35 Correct 39 ms 3348 KB Output is correct
36 Correct 11 ms 3348 KB Output is correct
37 Correct 40 ms 3348 KB Output is correct
38 Correct 50 ms 3348 KB Output is correct
39 Correct 46 ms 3348 KB Output is correct
40 Correct 44 ms 3348 KB Output is correct
41 Correct 52 ms 3348 KB Output is correct
42 Correct 23 ms 3348 KB Output is correct
43 Correct 23 ms 3348 KB Output is correct
44 Correct 35 ms 3348 KB Output is correct
45 Correct 60 ms 3348 KB Output is correct
46 Correct 47 ms 3348 KB Output is correct
47 Correct 54 ms 4796 KB Output is correct
48 Correct 36 ms 4796 KB Output is correct
49 Correct 38 ms 4796 KB Output is correct
50 Correct 29 ms 4796 KB Output is correct
51 Correct 71 ms 6756 KB Output is correct
52 Correct 71 ms 6884 KB Output is correct
53 Correct 53 ms 6884 KB Output is correct
54 Correct 6 ms 6884 KB Output is correct
55 Correct 6 ms 6884 KB Output is correct
56 Execution timed out 1055 ms 6884 KB Time limit exceeded
57 Halted 0 ms 0 KB -