Submission #230518

# Submission time Handle Problem Language Result Execution time Memory
230518 2020-05-10T09:53:17 Z AlexLuchianov Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 88044 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 30000;
int v[1 + nmax][2];
vector<int> g[1 + nmax];

unordered_map<int, int> dp[1 + nmax];

int seen[1 + nmax];

queue<pair<int,int>> q;

void processlevel(int node, int cost){
  if(seen[node] == 1)
    return ;
  seen[node] = 1;
  for(int h = 0; h < g[node].size(); h++){
    int jump2 = g[node][h];
    if(dp[node][jump2] == 0){
      dp[node][jump2] = cost;
      q.push({node, jump2});
    }
  }
}

int main()
{
  int n, m;
  cin >> n >> m;
  for(int i = 0;i < m; i++) {
    cin >> v[i][0] >> v[i][1];
    g[v[i][0]].push_back(v[i][1]);
  }
  processlevel(v[0][0], 1);

  while(0 < q.size()){
    int node = q.front().first;
    int jump = q.front().second;
    int cost = dp[node][jump];
    q.pop();

    if(0 <= node - jump)
      if(dp[node - jump][jump] == 0) {
        dp[node - jump][jump] = cost + 1;
        processlevel(node - jump, cost + 1);
        q.push({node - jump, jump});
      }
    if(node + jump < n)
      if(dp[node + jump][jump] == 0) {
        dp[node + jump][jump] = cost + 1;
        processlevel(node + jump, cost + 1);
        q.push({node + jump, jump});
      }
  }

  cout << dp[v[1][0]][v[1][1]] - 1;
  return 0;
}

Compilation message

skyscraper.cpp: In function 'void processlevel(int, int)':
skyscraper.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int h = 0; h < g[node].size(); h++){
                  ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 7 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 8 ms 2944 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 8 ms 2944 KB Output is correct
15 Correct 8 ms 2944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 8 ms 2944 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 7 ms 2944 KB Output is correct
15 Correct 7 ms 2944 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 10 ms 3328 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 8 ms 2944 KB Output is correct
21 Correct 7 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 8 ms 2944 KB Output is correct
24 Correct 10 ms 3328 KB Output is correct
25 Correct 9 ms 3072 KB Output is correct
26 Correct 8 ms 3072 KB Output is correct
27 Correct 8 ms 3072 KB Output is correct
28 Correct 12 ms 3840 KB Output is correct
29 Correct 17 ms 5248 KB Output is correct
30 Correct 9 ms 3456 KB Output is correct
31 Correct 13 ms 4352 KB Output is correct
32 Correct 10 ms 3712 KB Output is correct
33 Correct 33 ms 7808 KB Output is correct
34 Correct 29 ms 7800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 7 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 8 ms 2944 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 8 ms 2944 KB Output is correct
15 Correct 7 ms 2944 KB Output is correct
16 Correct 7 ms 2688 KB Output is correct
17 Correct 10 ms 3328 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 8 ms 2944 KB Output is correct
21 Correct 7 ms 2688 KB Output is correct
22 Correct 6 ms 2816 KB Output is correct
23 Correct 8 ms 3072 KB Output is correct
24 Correct 10 ms 3328 KB Output is correct
25 Correct 9 ms 3072 KB Output is correct
26 Correct 8 ms 3072 KB Output is correct
27 Correct 8 ms 3072 KB Output is correct
28 Correct 12 ms 3840 KB Output is correct
29 Correct 17 ms 5248 KB Output is correct
30 Correct 9 ms 3584 KB Output is correct
31 Correct 14 ms 4352 KB Output is correct
32 Correct 10 ms 3712 KB Output is correct
33 Correct 30 ms 7800 KB Output is correct
34 Correct 32 ms 7808 KB Output is correct
35 Correct 51 ms 7424 KB Output is correct
36 Correct 13 ms 3584 KB Output is correct
37 Correct 87 ms 10872 KB Output is correct
38 Correct 89 ms 10336 KB Output is correct
39 Correct 92 ms 10360 KB Output is correct
40 Correct 78 ms 10512 KB Output is correct
41 Correct 86 ms 10360 KB Output is correct
42 Correct 25 ms 3456 KB Output is correct
43 Correct 25 ms 3320 KB Output is correct
44 Correct 24 ms 3200 KB Output is correct
45 Correct 198 ms 23544 KB Output is correct
46 Correct 201 ms 23672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 8 ms 2944 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 8 ms 2944 KB Output is correct
15 Correct 7 ms 2944 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 10 ms 3328 KB Output is correct
18 Correct 7 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 8 ms 2944 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 8 ms 2944 KB Output is correct
24 Correct 10 ms 3328 KB Output is correct
25 Correct 9 ms 3072 KB Output is correct
26 Correct 8 ms 3072 KB Output is correct
27 Correct 8 ms 3072 KB Output is correct
28 Correct 12 ms 3840 KB Output is correct
29 Correct 17 ms 5248 KB Output is correct
30 Correct 9 ms 3584 KB Output is correct
31 Correct 13 ms 4352 KB Output is correct
32 Correct 10 ms 3712 KB Output is correct
33 Correct 32 ms 7856 KB Output is correct
34 Correct 32 ms 7808 KB Output is correct
35 Correct 53 ms 7544 KB Output is correct
36 Correct 13 ms 3584 KB Output is correct
37 Correct 92 ms 10872 KB Output is correct
38 Correct 77 ms 10360 KB Output is correct
39 Correct 80 ms 10360 KB Output is correct
40 Correct 74 ms 10360 KB Output is correct
41 Correct 77 ms 10360 KB Output is correct
42 Correct 26 ms 3476 KB Output is correct
43 Correct 25 ms 3328 KB Output is correct
44 Correct 27 ms 3200 KB Output is correct
45 Correct 217 ms 23672 KB Output is correct
46 Correct 191 ms 23672 KB Output is correct
47 Correct 457 ms 34808 KB Output is correct
48 Correct 25 ms 3584 KB Output is correct
49 Correct 24 ms 3584 KB Output is correct
50 Correct 19 ms 3304 KB Output is correct
51 Correct 184 ms 18040 KB Output is correct
52 Correct 194 ms 19192 KB Output is correct
53 Correct 55 ms 8312 KB Output is correct
54 Correct 9 ms 3712 KB Output is correct
55 Correct 11 ms 4224 KB Output is correct
56 Correct 35 ms 6008 KB Output is correct
57 Correct 169 ms 20880 KB Output is correct
58 Correct 32 ms 6648 KB Output is correct
59 Correct 49 ms 8056 KB Output is correct
60 Correct 52 ms 9208 KB Output is correct
61 Correct 49 ms 8568 KB Output is correct
62 Correct 276 ms 26336 KB Output is correct
63 Execution timed out 1088 ms 88044 KB Time limit exceeded
64 Halted 0 ms 0 KB -