답안 #49536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49536 2018-05-31T01:08:27 Z updown1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 5956 KB
/*
dijstra's on the location
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, N)
#define ffj For(j, 0, M)
#define ffa ffi ffj
#define w cout
#define e "\n"
#define s <<" "<<
#define pb push_back
#define mp make_pair
#define a first
#define b second
/// 500,000,000
const int MAXN = 30000, INF = 1000000000000000000;
/// Global Variables
int N, M, dist[MAXN], B[MAXN], P[MAXN];
bool vis[MAXN];
vector<int> dogs[MAXN];
priority_queue<pair<int, int> > next1; /// (-dist, loc)
 
void go(int loc) {
    vis[loc] = true;
    For (i, 0, dogs[loc].size()) {
        int x = dogs[loc][i];
        for (int j=loc+P[x], add = 1; j<N; j+= P[x], add++) if (dist[loc]+add < dist[j]) {
            dist[j] = min(dist[j], dist[loc]+add);
            next1.push(mp(-dist[j], j));
        }
        for (int j=loc-P[x], add = 1; j>= 0; j-= P[x], add++) if (dist[loc]+add < dist[j]) {
            dist[j] = min(dist[j], dist[loc]+add);
            next1.push(mp(-dist[j], j));
        }
    }
}
 
main() {
    //ifstream cin("test.in");
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    ffi dist[i] = INF;
    ffj {
        cin >> B[j] >> P[j];
        dogs[B[j]].pb(j);
    }
    next1.push(mp(0, B[0]));
    dist[B[0]] = 0;
    while (!next1.empty()) {
        int i = next1.top().b; next1.pop();
        if (!vis[i]) go(i);
    }
    if (dist[B[1]] == INF) w<< -1<<e;
    else w<< dist[B[1]]<<e;
}

Compilation message

skyscraper.cpp: In function 'void go(ll)':
skyscraper.cpp:8:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define For(i, a, b) for(int i=a; i<b; i++)
skyscraper.cpp:29:10:
     For (i, 0, dogs[loc].size()) {
          ~~~~~~~~~~~~~~~~~~~~~~     
skyscraper.cpp:29:5: note: in expansion of macro 'For'
     For (i, 0, dogs[loc].size()) {
     ^~~
skyscraper.cpp: At global scope:
skyscraper.cpp:42:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1256 KB Output is correct
3 Correct 3 ms 1256 KB Output is correct
4 Correct 4 ms 1256 KB Output is correct
5 Correct 3 ms 1336 KB Output is correct
6 Correct 3 ms 1336 KB Output is correct
7 Correct 3 ms 1336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1336 KB Output is correct
2 Correct 3 ms 1336 KB Output is correct
3 Correct 3 ms 1336 KB Output is correct
4 Correct 3 ms 1336 KB Output is correct
5 Correct 3 ms 1336 KB Output is correct
6 Correct 3 ms 1336 KB Output is correct
7 Correct 4 ms 1336 KB Output is correct
8 Correct 3 ms 1336 KB Output is correct
9 Correct 4 ms 1388 KB Output is correct
10 Correct 3 ms 1388 KB Output is correct
11 Correct 3 ms 1404 KB Output is correct
12 Correct 3 ms 1404 KB Output is correct
13 Correct 3 ms 1404 KB Output is correct
14 Correct 3 ms 1404 KB Output is correct
15 Correct 4 ms 1404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1404 KB Output is correct
2 Correct 3 ms 1404 KB Output is correct
3 Correct 2 ms 1404 KB Output is correct
4 Correct 3 ms 1404 KB Output is correct
5 Correct 3 ms 1404 KB Output is correct
6 Correct 3 ms 1404 KB Output is correct
7 Correct 3 ms 1404 KB Output is correct
8 Correct 3 ms 1404 KB Output is correct
9 Correct 2 ms 1404 KB Output is correct
10 Correct 3 ms 1404 KB Output is correct
11 Correct 3 ms 1412 KB Output is correct
12 Correct 4 ms 1412 KB Output is correct
13 Correct 4 ms 1412 KB Output is correct
14 Correct 3 ms 1412 KB Output is correct
15 Correct 4 ms 1412 KB Output is correct
16 Correct 3 ms 1412 KB Output is correct
17 Correct 4 ms 1412 KB Output is correct
18 Correct 3 ms 1412 KB Output is correct
19 Correct 3 ms 1412 KB Output is correct
20 Correct 8 ms 1532 KB Output is correct
21 Correct 3 ms 1532 KB Output is correct
22 Correct 3 ms 1532 KB Output is correct
23 Correct 3 ms 1532 KB Output is correct
24 Correct 4 ms 1532 KB Output is correct
25 Correct 5 ms 1532 KB Output is correct
26 Correct 8 ms 1532 KB Output is correct
27 Correct 10 ms 1532 KB Output is correct
28 Correct 14 ms 1532 KB Output is correct
29 Correct 4 ms 1532 KB Output is correct
30 Correct 3 ms 1532 KB Output is correct
31 Correct 4 ms 1532 KB Output is correct
32 Correct 5 ms 1532 KB Output is correct
33 Correct 5 ms 1660 KB Output is correct
34 Correct 6 ms 1788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1788 KB Output is correct
2 Correct 4 ms 1788 KB Output is correct
3 Correct 3 ms 1788 KB Output is correct
4 Correct 3 ms 1788 KB Output is correct
5 Correct 3 ms 1788 KB Output is correct
6 Correct 3 ms 1788 KB Output is correct
7 Correct 3 ms 1788 KB Output is correct
8 Correct 3 ms 1788 KB Output is correct
9 Correct 2 ms 1788 KB Output is correct
10 Correct 3 ms 1788 KB Output is correct
11 Correct 3 ms 1788 KB Output is correct
12 Correct 4 ms 1788 KB Output is correct
13 Correct 3 ms 1788 KB Output is correct
14 Correct 4 ms 1788 KB Output is correct
15 Correct 3 ms 1788 KB Output is correct
16 Correct 3 ms 1788 KB Output is correct
17 Correct 3 ms 1788 KB Output is correct
18 Correct 3 ms 1788 KB Output is correct
19 Correct 3 ms 1788 KB Output is correct
20 Correct 8 ms 1788 KB Output is correct
21 Correct 4 ms 1788 KB Output is correct
22 Correct 4 ms 1788 KB Output is correct
23 Correct 5 ms 1788 KB Output is correct
24 Correct 4 ms 1788 KB Output is correct
25 Correct 6 ms 1788 KB Output is correct
26 Correct 10 ms 1788 KB Output is correct
27 Correct 8 ms 1788 KB Output is correct
28 Correct 3 ms 1788 KB Output is correct
29 Correct 5 ms 1788 KB Output is correct
30 Correct 4 ms 1788 KB Output is correct
31 Correct 5 ms 1788 KB Output is correct
32 Correct 3 ms 1788 KB Output is correct
33 Correct 6 ms 1788 KB Output is correct
34 Correct 7 ms 1788 KB Output is correct
35 Correct 12 ms 2172 KB Output is correct
36 Correct 5 ms 2172 KB Output is correct
37 Correct 12 ms 2236 KB Output is correct
38 Correct 15 ms 2428 KB Output is correct
39 Correct 29 ms 2428 KB Output is correct
40 Correct 14 ms 2428 KB Output is correct
41 Correct 17 ms 2428 KB Output is correct
42 Correct 116 ms 2428 KB Output is correct
43 Correct 61 ms 2428 KB Output is correct
44 Correct 64 ms 2428 KB Output is correct
45 Correct 11 ms 2428 KB Output is correct
46 Correct 13 ms 2428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2428 KB Output is correct
2 Correct 3 ms 2428 KB Output is correct
3 Correct 4 ms 2428 KB Output is correct
4 Correct 3 ms 2428 KB Output is correct
5 Correct 3 ms 2428 KB Output is correct
6 Correct 3 ms 2428 KB Output is correct
7 Correct 3 ms 2428 KB Output is correct
8 Correct 3 ms 2428 KB Output is correct
9 Correct 3 ms 2428 KB Output is correct
10 Correct 4 ms 2428 KB Output is correct
11 Correct 3 ms 2428 KB Output is correct
12 Correct 3 ms 2428 KB Output is correct
13 Correct 4 ms 2428 KB Output is correct
14 Correct 3 ms 2428 KB Output is correct
15 Correct 3 ms 2428 KB Output is correct
16 Correct 3 ms 2428 KB Output is correct
17 Correct 4 ms 2428 KB Output is correct
18 Correct 4 ms 2428 KB Output is correct
19 Correct 3 ms 2428 KB Output is correct
20 Correct 14 ms 2428 KB Output is correct
21 Correct 3 ms 2428 KB Output is correct
22 Correct 3 ms 2428 KB Output is correct
23 Correct 3 ms 2428 KB Output is correct
24 Correct 4 ms 2428 KB Output is correct
25 Correct 3 ms 2428 KB Output is correct
26 Correct 6 ms 2428 KB Output is correct
27 Correct 8 ms 2428 KB Output is correct
28 Correct 3 ms 2428 KB Output is correct
29 Correct 4 ms 2428 KB Output is correct
30 Correct 4 ms 2428 KB Output is correct
31 Correct 4 ms 2428 KB Output is correct
32 Correct 5 ms 2428 KB Output is correct
33 Correct 6 ms 2428 KB Output is correct
34 Correct 5 ms 2428 KB Output is correct
35 Correct 11 ms 2428 KB Output is correct
36 Correct 13 ms 2428 KB Output is correct
37 Correct 11 ms 2428 KB Output is correct
38 Correct 14 ms 2428 KB Output is correct
39 Correct 14 ms 2428 KB Output is correct
40 Correct 14 ms 2428 KB Output is correct
41 Correct 13 ms 2432 KB Output is correct
42 Correct 67 ms 2432 KB Output is correct
43 Correct 67 ms 2432 KB Output is correct
44 Correct 82 ms 2432 KB Output is correct
45 Correct 10 ms 2432 KB Output is correct
46 Correct 10 ms 2432 KB Output is correct
47 Correct 28 ms 3448 KB Output is correct
48 Correct 12 ms 3448 KB Output is correct
49 Correct 15 ms 3448 KB Output is correct
50 Correct 15 ms 3448 KB Output is correct
51 Correct 44 ms 4852 KB Output is correct
52 Correct 60 ms 4852 KB Output is correct
53 Correct 26 ms 4852 KB Output is correct
54 Correct 5 ms 4852 KB Output is correct
55 Correct 5 ms 4852 KB Output is correct
56 Correct 900 ms 4852 KB Output is correct
57 Correct 72 ms 5956 KB Output is correct
58 Execution timed out 1014 ms 5956 KB Time limit exceeded
59 Halted 0 ms 0 KB -