답안 #45731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45731 2018-04-16T05:00:18 Z Talant Jakarta Skyscrapers (APIO15_skyscraper) C++17
36 / 100
1000 ms 69772 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long

using namespace std;

typedef long long ll;

const int inf = (int)1e15 + 7;
const int N = (int)2e5 + 7;

int n,m;
int b[N],p[N];
int d[N];

vector <pair<int,int> > g[N];
priority_queue<pair<int,int> > q;

bool check (int l,int r) {
      if (abs(b[r] - b[l]) % p[l] == 0)
            return true;
      return false;
}
int f (int l,int r) {
      return (abs(b[r] - b[l]) / p[l]);
}
main () {
      cin >> n >> m;

      for (int i = 1; i <= m; i ++) {
            cin >> b[i] >> p[i];
            b[i] ++;
      }
      for (int i = 1; i <= m; i ++) {
            for (int j = 1; j <= m; j ++) {
                  if (i != j && check(i,j))
                        g[i].pb(mk(j,f(i,j)));
            }
      }
      for (int i = 1; i <= m; i ++)
            d[i] = inf;
      d[1] = 0;
      q.push({0,1});

      while (!q.empty()) {
            int v = q.top().sc,cur = -q.top().fr;
            q.pop();

            if (cur > d[v])
                  continue;

            for (auto to : g[v]) {
                  if (d[v] + to.sc < d[to.fr]) {
                        d[to.fr] = d[v] + to.sc;
                        q.push({-d[to.fr],to.fr});
                  }
            }
      }
      if (d[2] == inf)
            puts("-1");
      else
            cout << d[2] << endl;
}

Compilation message

skyscraper.cpp:32:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4984 KB Output is correct
2 Correct 5 ms 5096 KB Output is correct
3 Correct 5 ms 5164 KB Output is correct
4 Correct 5 ms 5164 KB Output is correct
5 Correct 6 ms 5224 KB Output is correct
6 Correct 5 ms 5296 KB Output is correct
7 Correct 6 ms 5296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5296 KB Output is correct
2 Correct 5 ms 5296 KB Output is correct
3 Correct 5 ms 5296 KB Output is correct
4 Correct 7 ms 5296 KB Output is correct
5 Correct 6 ms 5296 KB Output is correct
6 Correct 5 ms 5356 KB Output is correct
7 Correct 6 ms 5356 KB Output is correct
8 Correct 5 ms 5356 KB Output is correct
9 Correct 6 ms 5356 KB Output is correct
10 Correct 9 ms 5500 KB Output is correct
11 Correct 98 ms 9596 KB Output is correct
12 Correct 142 ms 69244 KB Output is correct
13 Correct 136 ms 69512 KB Output is correct
14 Correct 67 ms 69512 KB Output is correct
15 Correct 104 ms 69512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 69512 KB Output is correct
2 Correct 5 ms 69512 KB Output is correct
3 Correct 6 ms 69512 KB Output is correct
4 Correct 6 ms 69512 KB Output is correct
5 Correct 6 ms 69512 KB Output is correct
6 Correct 6 ms 69512 KB Output is correct
7 Correct 5 ms 69512 KB Output is correct
8 Correct 5 ms 69512 KB Output is correct
9 Correct 6 ms 69512 KB Output is correct
10 Correct 9 ms 69512 KB Output is correct
11 Correct 73 ms 69512 KB Output is correct
12 Correct 139 ms 69512 KB Output is correct
13 Correct 145 ms 69656 KB Output is correct
14 Correct 67 ms 69656 KB Output is correct
15 Correct 67 ms 69656 KB Output is correct
16 Correct 17 ms 69656 KB Output is correct
17 Correct 56 ms 69656 KB Output is correct
18 Correct 19 ms 69656 KB Output is correct
19 Correct 10 ms 69656 KB Output is correct
20 Correct 141 ms 69672 KB Output is correct
21 Correct 25 ms 69672 KB Output is correct
22 Correct 18 ms 69672 KB Output is correct
23 Correct 24 ms 69672 KB Output is correct
24 Correct 56 ms 69672 KB Output is correct
25 Correct 63 ms 69672 KB Output is correct
26 Correct 135 ms 69672 KB Output is correct
27 Correct 131 ms 69672 KB Output is correct
28 Correct 65 ms 69672 KB Output is correct
29 Correct 15 ms 69672 KB Output is correct
30 Correct 6 ms 69672 KB Output is correct
31 Correct 12 ms 69672 KB Output is correct
32 Correct 9 ms 69672 KB Output is correct
33 Correct 68 ms 69672 KB Output is correct
34 Correct 67 ms 69672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 69672 KB Output is correct
2 Correct 5 ms 69672 KB Output is correct
3 Correct 5 ms 69672 KB Output is correct
4 Correct 5 ms 69672 KB Output is correct
5 Correct 6 ms 69672 KB Output is correct
6 Correct 6 ms 69672 KB Output is correct
7 Correct 6 ms 69672 KB Output is correct
8 Correct 6 ms 69672 KB Output is correct
9 Correct 5 ms 69672 KB Output is correct
10 Correct 9 ms 69672 KB Output is correct
11 Correct 85 ms 69672 KB Output is correct
12 Correct 140 ms 69672 KB Output is correct
13 Correct 137 ms 69772 KB Output is correct
14 Correct 98 ms 69772 KB Output is correct
15 Correct 67 ms 69772 KB Output is correct
16 Correct 18 ms 69772 KB Output is correct
17 Correct 56 ms 69772 KB Output is correct
18 Correct 19 ms 69772 KB Output is correct
19 Correct 10 ms 69772 KB Output is correct
20 Correct 136 ms 69772 KB Output is correct
21 Correct 25 ms 69772 KB Output is correct
22 Correct 13 ms 69772 KB Output is correct
23 Correct 19 ms 69772 KB Output is correct
24 Correct 57 ms 69772 KB Output is correct
25 Correct 65 ms 69772 KB Output is correct
26 Correct 138 ms 69772 KB Output is correct
27 Correct 135 ms 69772 KB Output is correct
28 Correct 78 ms 69772 KB Output is correct
29 Correct 16 ms 69772 KB Output is correct
30 Correct 7 ms 69772 KB Output is correct
31 Correct 11 ms 69772 KB Output is correct
32 Correct 10 ms 69772 KB Output is correct
33 Correct 66 ms 69772 KB Output is correct
34 Correct 68 ms 69772 KB Output is correct
35 Execution timed out 1079 ms 69772 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 69772 KB Output is correct
2 Correct 6 ms 69772 KB Output is correct
3 Correct 6 ms 69772 KB Output is correct
4 Correct 6 ms 69772 KB Output is correct
5 Correct 7 ms 69772 KB Output is correct
6 Correct 6 ms 69772 KB Output is correct
7 Correct 5 ms 69772 KB Output is correct
8 Correct 6 ms 69772 KB Output is correct
9 Correct 6 ms 69772 KB Output is correct
10 Correct 9 ms 69772 KB Output is correct
11 Correct 69 ms 69772 KB Output is correct
12 Correct 136 ms 69772 KB Output is correct
13 Correct 135 ms 69772 KB Output is correct
14 Correct 67 ms 69772 KB Output is correct
15 Correct 66 ms 69772 KB Output is correct
16 Correct 23 ms 69772 KB Output is correct
17 Correct 88 ms 69772 KB Output is correct
18 Correct 20 ms 69772 KB Output is correct
19 Correct 11 ms 69772 KB Output is correct
20 Correct 136 ms 69772 KB Output is correct
21 Correct 26 ms 69772 KB Output is correct
22 Correct 15 ms 69772 KB Output is correct
23 Correct 19 ms 69772 KB Output is correct
24 Correct 55 ms 69772 KB Output is correct
25 Correct 60 ms 69772 KB Output is correct
26 Correct 129 ms 69772 KB Output is correct
27 Correct 130 ms 69772 KB Output is correct
28 Correct 63 ms 69772 KB Output is correct
29 Correct 16 ms 69772 KB Output is correct
30 Correct 6 ms 69772 KB Output is correct
31 Correct 11 ms 69772 KB Output is correct
32 Correct 10 ms 69772 KB Output is correct
33 Correct 68 ms 69772 KB Output is correct
34 Correct 67 ms 69772 KB Output is correct
35 Execution timed out 1088 ms 69772 KB Time limit exceeded
36 Halted 0 ms 0 KB -