Submission #60619

# Submission time Handle Problem Language Result Execution time Memory
60619 2018-07-24T11:49:25 Z Flugan42 Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 6868 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;

int main(){
  cin >> n >> m; b.assign(m,0); p.assign(m,0);
  rep(i,0,m) cin >> b[i] >> 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);
  vector<set<ll> > jumps;
  set<ll> __; jumps.assign(n,__);
  rep(i,0,n) rep(j,0,sz(dog[i])){
    jumps[i].insert(p[dog[i][j]]);
  }
  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 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 4 ms 500 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 3 ms 500 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 3 ms 620 KB Output is correct
6 Correct 3 ms 620 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
8 Correct 4 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 4 ms 624 KB Output is correct
11 Correct 5 ms 752 KB Output is correct
12 Correct 4 ms 752 KB Output is correct
13 Correct 5 ms 752 KB Output is correct
14 Correct 4 ms 752 KB Output is correct
15 Correct 5 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 752 KB Output is correct
2 Correct 3 ms 752 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 3 ms 752 KB Output is correct
5 Correct 3 ms 752 KB Output is correct
6 Correct 3 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
8 Correct 2 ms 752 KB Output is correct
9 Correct 2 ms 752 KB Output is correct
10 Correct 3 ms 752 KB Output is correct
11 Correct 4 ms 752 KB Output is correct
12 Correct 4 ms 752 KB Output is correct
13 Correct 4 ms 752 KB Output is correct
14 Correct 3 ms 752 KB Output is correct
15 Correct 4 ms 752 KB Output is correct
16 Correct 4 ms 752 KB Output is correct
17 Correct 4 ms 752 KB Output is correct
18 Correct 5 ms 752 KB Output is correct
19 Correct 4 ms 752 KB Output is correct
20 Correct 11 ms 1004 KB Output is correct
21 Correct 5 ms 1004 KB Output is correct
22 Correct 4 ms 1004 KB Output is correct
23 Correct 5 ms 1004 KB Output is correct
24 Correct 5 ms 1004 KB Output is correct
25 Correct 5 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 5 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1004 KB Output is correct
2 Correct 2 ms 1004 KB Output is correct
3 Correct 2 ms 1004 KB Output is correct
4 Correct 2 ms 1004 KB Output is correct
5 Correct 3 ms 1004 KB Output is correct
6 Correct 2 ms 1004 KB Output is correct
7 Correct 3 ms 1004 KB Output is correct
8 Correct 2 ms 1004 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 3 ms 1004 KB Output is correct
11 Correct 4 ms 1004 KB Output is correct
12 Correct 4 ms 1004 KB Output is correct
13 Correct 4 ms 1004 KB Output is correct
14 Correct 6 ms 1004 KB Output is correct
15 Correct 5 ms 1004 KB Output is correct
16 Correct 2 ms 1004 KB Output is correct
17 Correct 6 ms 1004 KB Output is correct
18 Correct 5 ms 1004 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 15 ms 1004 KB Output is correct
21 Correct 4 ms 1004 KB Output is correct
22 Correct 4 ms 1004 KB Output is correct
23 Correct 5 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 5 ms 1004 KB Output is correct
30 Correct 3 ms 1004 KB Output is correct
31 Correct 4 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 40 ms 2684 KB Output is correct
36 Correct 8 ms 2684 KB Output is correct
37 Correct 26 ms 2684 KB Output is correct
38 Correct 29 ms 3196 KB Output is correct
39 Correct 31 ms 3196 KB Output is correct
40 Correct 33 ms 3196 KB Output is correct
41 Correct 36 ms 3196 KB Output is correct
42 Correct 25 ms 3196 KB Output is correct
43 Correct 21 ms 3196 KB Output is correct
44 Correct 40 ms 3196 KB Output is correct
45 Correct 31 ms 3196 KB Output is correct
46 Correct 30 ms 3196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3196 KB Output is correct
2 Correct 2 ms 3196 KB Output is correct
3 Correct 2 ms 3196 KB Output is correct
4 Correct 3 ms 3196 KB Output is correct
5 Correct 3 ms 3196 KB Output is correct
6 Correct 2 ms 3196 KB Output is correct
7 Correct 3 ms 3196 KB Output is correct
8 Correct 2 ms 3196 KB Output is correct
9 Correct 2 ms 3196 KB Output is correct
10 Correct 4 ms 3196 KB Output is correct
11 Correct 3 ms 3196 KB Output is correct
12 Correct 3 ms 3196 KB Output is correct
13 Correct 4 ms 3196 KB Output is correct
14 Correct 4 ms 3196 KB Output is correct
15 Correct 4 ms 3196 KB Output is correct
16 Correct 4 ms 3196 KB Output is correct
17 Correct 5 ms 3196 KB Output is correct
18 Correct 3 ms 3196 KB Output is correct
19 Correct 4 ms 3196 KB Output is correct
20 Correct 14 ms 3196 KB Output is correct
21 Correct 3 ms 3196 KB Output is correct
22 Correct 3 ms 3196 KB Output is correct
23 Correct 3 ms 3196 KB Output is correct
24 Correct 5 ms 3196 KB Output is correct
25 Correct 4 ms 3196 KB Output is correct
26 Correct 4 ms 3196 KB Output is correct
27 Correct 4 ms 3196 KB Output is correct
28 Correct 6 ms 3196 KB Output is correct
29 Correct 4 ms 3196 KB Output is correct
30 Correct 3 ms 3196 KB Output is correct
31 Correct 3 ms 3196 KB Output is correct
32 Correct 4 ms 3196 KB Output is correct
33 Correct 5 ms 3196 KB Output is correct
34 Correct 5 ms 3196 KB Output is correct
35 Correct 27 ms 3196 KB Output is correct
36 Correct 6 ms 3196 KB Output is correct
37 Correct 17 ms 3196 KB Output is correct
38 Correct 32 ms 3196 KB Output is correct
39 Correct 35 ms 3196 KB Output is correct
40 Correct 32 ms 3196 KB Output is correct
41 Correct 38 ms 3196 KB Output is correct
42 Correct 23 ms 3196 KB Output is correct
43 Correct 23 ms 3196 KB Output is correct
44 Correct 29 ms 3196 KB Output is correct
45 Correct 28 ms 3196 KB Output is correct
46 Correct 29 ms 3196 KB Output is correct
47 Correct 33 ms 4760 KB Output is correct
48 Correct 33 ms 4760 KB Output is correct
49 Correct 29 ms 4760 KB Output is correct
50 Correct 20 ms 4760 KB Output is correct
51 Correct 76 ms 6772 KB Output is correct
52 Correct 57 ms 6868 KB Output is correct
53 Correct 44 ms 6868 KB Output is correct
54 Correct 6 ms 6868 KB Output is correct
55 Correct 5 ms 6868 KB Output is correct
56 Execution timed out 1052 ms 6868 KB Time limit exceeded
57 Halted 0 ms 0 KB -