답안 #60503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60503 2018-07-24T09:18:48 Z dukati8 Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 7032 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)
#define all(x) x.begin(),x.end()

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int> > doges(m);
  vector<set<int> > scrapers(n); //For each scraper a set of all dogs that reside there from beginning, or rather their jumps
  rep(i,0,m) {
    int b,p;
    cin >> b >> p;
    doges[i]=make_pair(b,abs(p));
    scrapers[b].insert(-p);
  }
  queue<vector<int> > order; //Each element is <numjumps,position, jumplen, 1 or 0 for left/right>
  int dp[n];
  rep (i,0,n) dp[i]=1000000000;
  int start,stop;
  start=doges[0].first;
  stop=doges[1].first;
  dp[start]=0;
  for (auto p:scrapers[start]) {
    order.push({0,start,-p,1});
    order.push({0,start,-p,0});
  }
  while (!order.empty()) {
    auto curr =order.front();
    order.pop();
    int num,pos,p;
    num=-curr[0];
    pos=curr[1];
    p=curr[2];
    bool left = curr[3]==1;
    int next;
    if (left) next=pos+p;
    else next=pos-p;
    if (next>=0 && next<n) {
      if (next==stop) {dp[next]=min(num+1,dp[next]); break;}
      if (dp[next]>num+1) {
        dp[next]=num+1;
        for (auto pn:scrapers[next]){
          if (-pn!=p) {
            order.push({-num-1,next,-pn,1});
            order.push({-num-1,next,-pn,0});
          }
        }
        order.push({-num-1,next,p,curr[3]});
      }
      else if (scrapers[next].find(p)==scrapers[next].end()) {
        order.push({-num-1,next,p,curr[3]});
      }
    }
  }
  if (dp[stop] == 1000000000) cout << -1 << endl;
  else cout << dp[stop]<< endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
11 Correct 4 ms 688 KB Output is correct
12 Correct 4 ms 688 KB Output is correct
13 Correct 3 ms 688 KB Output is correct
14 Correct 5 ms 836 KB Output is correct
15 Correct 5 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 3 ms 876 KB Output is correct
4 Correct 3 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 3 ms 876 KB Output is correct
7 Correct 3 ms 876 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
11 Correct 4 ms 876 KB Output is correct
12 Correct 5 ms 876 KB Output is correct
13 Correct 3 ms 876 KB Output is correct
14 Correct 5 ms 876 KB Output is correct
15 Correct 4 ms 876 KB Output is correct
16 Correct 4 ms 876 KB Output is correct
17 Correct 4 ms 876 KB Output is correct
18 Correct 4 ms 876 KB Output is correct
19 Correct 4 ms 876 KB Output is correct
20 Correct 4 ms 876 KB Output is correct
21 Correct 4 ms 876 KB Output is correct
22 Correct 4 ms 876 KB Output is correct
23 Correct 4 ms 876 KB Output is correct
24 Correct 6 ms 876 KB Output is correct
25 Correct 7 ms 876 KB Output is correct
26 Correct 4 ms 876 KB Output is correct
27 Correct 4 ms 876 KB Output is correct
28 Correct 8 ms 876 KB Output is correct
29 Correct 10 ms 876 KB Output is correct
30 Correct 4 ms 876 KB Output is correct
31 Correct 6 ms 876 KB Output is correct
32 Correct 7 ms 876 KB Output is correct
33 Correct 19 ms 1020 KB Output is correct
34 Correct 12 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1020 KB Output is correct
2 Correct 3 ms 1020 KB Output is correct
3 Correct 3 ms 1020 KB Output is correct
4 Correct 3 ms 1020 KB Output is correct
5 Correct 2 ms 1020 KB Output is correct
6 Correct 3 ms 1020 KB Output is correct
7 Correct 1 ms 1020 KB Output is correct
8 Correct 3 ms 1020 KB Output is correct
9 Correct 3 ms 1020 KB Output is correct
10 Correct 4 ms 1020 KB Output is correct
11 Correct 4 ms 1020 KB Output is correct
12 Correct 3 ms 1020 KB Output is correct
13 Correct 3 ms 1020 KB Output is correct
14 Correct 7 ms 1020 KB Output is correct
15 Correct 5 ms 1020 KB Output is correct
16 Correct 4 ms 1020 KB Output is correct
17 Correct 7 ms 1020 KB Output is correct
18 Correct 4 ms 1020 KB Output is correct
19 Correct 4 ms 1020 KB Output is correct
20 Correct 5 ms 1020 KB Output is correct
21 Correct 4 ms 1020 KB Output is correct
22 Correct 3 ms 1020 KB Output is correct
23 Correct 5 ms 1020 KB Output is correct
24 Correct 6 ms 1020 KB Output is correct
25 Correct 4 ms 1020 KB Output is correct
26 Correct 5 ms 1020 KB Output is correct
27 Correct 5 ms 1020 KB Output is correct
28 Correct 7 ms 1020 KB Output is correct
29 Correct 10 ms 1020 KB Output is correct
30 Correct 6 ms 1020 KB Output is correct
31 Correct 7 ms 1020 KB Output is correct
32 Correct 7 ms 1020 KB Output is correct
33 Correct 21 ms 1020 KB Output is correct
34 Correct 12 ms 1020 KB Output is correct
35 Correct 64 ms 4348 KB Output is correct
36 Correct 7 ms 4348 KB Output is correct
37 Correct 27 ms 4348 KB Output is correct
38 Correct 40 ms 4348 KB Output is correct
39 Correct 30 ms 4348 KB Output is correct
40 Correct 34 ms 4348 KB Output is correct
41 Correct 53 ms 4864 KB Output is correct
42 Correct 21 ms 4864 KB Output is correct
43 Correct 30 ms 4864 KB Output is correct
44 Correct 23 ms 4864 KB Output is correct
45 Correct 135 ms 5668 KB Output is correct
46 Correct 79 ms 5668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5668 KB Output is correct
2 Correct 3 ms 5668 KB Output is correct
3 Correct 3 ms 5668 KB Output is correct
4 Correct 3 ms 5668 KB Output is correct
5 Correct 3 ms 5668 KB Output is correct
6 Correct 2 ms 5668 KB Output is correct
7 Correct 3 ms 5668 KB Output is correct
8 Correct 3 ms 5668 KB Output is correct
9 Correct 3 ms 5668 KB Output is correct
10 Correct 3 ms 5668 KB Output is correct
11 Correct 5 ms 5668 KB Output is correct
12 Correct 5 ms 5668 KB Output is correct
13 Correct 3 ms 5668 KB Output is correct
14 Correct 8 ms 5668 KB Output is correct
15 Correct 4 ms 5668 KB Output is correct
16 Correct 3 ms 5668 KB Output is correct
17 Correct 5 ms 5668 KB Output is correct
18 Correct 4 ms 5668 KB Output is correct
19 Correct 3 ms 5668 KB Output is correct
20 Correct 5 ms 5668 KB Output is correct
21 Correct 4 ms 5668 KB Output is correct
22 Correct 5 ms 5668 KB Output is correct
23 Correct 5 ms 5668 KB Output is correct
24 Correct 7 ms 5668 KB Output is correct
25 Correct 6 ms 5668 KB Output is correct
26 Correct 4 ms 5668 KB Output is correct
27 Correct 5 ms 5668 KB Output is correct
28 Correct 8 ms 5668 KB Output is correct
29 Correct 16 ms 5668 KB Output is correct
30 Correct 6 ms 5668 KB Output is correct
31 Correct 10 ms 5668 KB Output is correct
32 Correct 6 ms 5668 KB Output is correct
33 Correct 32 ms 5668 KB Output is correct
34 Correct 15 ms 5668 KB Output is correct
35 Correct 54 ms 5668 KB Output is correct
36 Correct 7 ms 5668 KB Output is correct
37 Correct 39 ms 5668 KB Output is correct
38 Correct 68 ms 5668 KB Output is correct
39 Correct 44 ms 5668 KB Output is correct
40 Correct 35 ms 5668 KB Output is correct
41 Correct 61 ms 5668 KB Output is correct
42 Correct 21 ms 5668 KB Output is correct
43 Correct 23 ms 5668 KB Output is correct
44 Correct 36 ms 5668 KB Output is correct
45 Correct 165 ms 5724 KB Output is correct
46 Correct 98 ms 5760 KB Output is correct
47 Correct 31 ms 5760 KB Output is correct
48 Correct 32 ms 5760 KB Output is correct
49 Correct 29 ms 5760 KB Output is correct
50 Correct 20 ms 5760 KB Output is correct
51 Correct 65 ms 5760 KB Output is correct
52 Correct 58 ms 5760 KB Output is correct
53 Correct 48 ms 5760 KB Output is correct
54 Correct 8 ms 5760 KB Output is correct
55 Correct 9 ms 5760 KB Output is correct
56 Correct 49 ms 5760 KB Output is correct
57 Correct 6 ms 5760 KB Output is correct
58 Correct 37 ms 5760 KB Output is correct
59 Correct 43 ms 5760 KB Output is correct
60 Correct 30 ms 5760 KB Output is correct
61 Correct 47 ms 5760 KB Output is correct
62 Correct 164 ms 5760 KB Output is correct
63 Correct 549 ms 5760 KB Output is correct
64 Correct 730 ms 5760 KB Output is correct
65 Correct 890 ms 5760 KB Output is correct
66 Execution timed out 1086 ms 7032 KB Time limit exceeded
67 Halted 0 ms 0 KB -