답안 #482594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
482594 2021-10-25T18:09:51 Z beaconmc Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
196 ms 67756 KB
#include <bits/stdc++.h>
 
typedef long long ll;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
 
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
  
#define ordered_set tree<ll, null_type,greater_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
 
int n,m;
int a,b,baka,imposter,sus, countz,sussy;
 
vector<pair<int, int>> edges[30000];
set <int> stuff[30000];
 
int dists[30001];
 
int main(){
    FOR(i, 0, 30001){
        dists[i] = 2147483647;
    }
    cin >> n>>m;
    FOR(i, 0, m){
        cin >> a >> b;
        if(i==0) imposter = a;
        if (i==1) baka = a;
        stuff[a].insert(b);
    }
    FOR(k, 0, n){
        for(auto&i : stuff[k]){
            sus = k;
            sussy = i;
            countz = 0;
            while ((sus+sussy)<n){
                sus += sussy;
                countz++;
                edges[k].push_back(make_pair(sus, countz));
                if (stuff[sus].find(i) != stuff[sus].end()) break;
            }
            sus = k;
            countz = 0;
            
            while ((sus-sussy)>=0){
                sus -= sussy;
                countz++;
                edges[k].push_back(make_pair(sus, countz));
                if (stuff[sus].find(i) != stuff[sus].end()) break;
            }
        }
    }
    int src=imposter;
    
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    dists[src] = 0;
    pq.push({0, src});
 
	while (pq.size()) {
        int cdist, node;
        pair<int, int> suz = pq.top();
        cdist = suz.first; node=suz.second;
        pq.pop();
		if (cdist != dists[node]) continue;
 
		for (auto& i : edges[node]) {
			if (cdist+i.second < dists[i.first]) {
				pq.push({dists[i.first] = cdist+i.second, i.first});
			}
		}
	}
    if (dists[baka] != 2147483647){
        cout << dists[baka];
    }else{
        cout << -1;
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2508 KB Output is correct
2 Correct 1 ms 2508 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 2 ms 2508 KB Output is correct
5 Correct 1 ms 2508 KB Output is correct
6 Correct 2 ms 2508 KB Output is correct
7 Correct 2 ms 2508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2508 KB Output is correct
2 Correct 1 ms 2508 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 1 ms 2508 KB Output is correct
6 Correct 2 ms 2508 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 2 ms 2508 KB Output is correct
9 Correct 2 ms 2508 KB Output is correct
10 Correct 2 ms 2508 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2508 KB Output is correct
13 Correct 2 ms 2508 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 3 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2508 KB Output is correct
2 Correct 1 ms 2508 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 2 ms 2508 KB Output is correct
5 Correct 2 ms 2508 KB Output is correct
6 Correct 2 ms 2508 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2508 KB Output is correct
9 Correct 1 ms 2508 KB Output is correct
10 Correct 2 ms 2508 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2508 KB Output is correct
13 Correct 2 ms 2508 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 3 ms 2636 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 4 ms 2764 KB Output is correct
18 Correct 3 ms 2548 KB Output is correct
19 Correct 2 ms 2508 KB Output is correct
20 Correct 4 ms 2636 KB Output is correct
21 Correct 2 ms 2508 KB Output is correct
22 Correct 2 ms 2520 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 4 ms 2764 KB Output is correct
25 Correct 4 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 2508 KB Output is correct
28 Correct 3 ms 2764 KB Output is correct
29 Correct 5 ms 3276 KB Output is correct
30 Correct 3 ms 2764 KB Output is correct
31 Correct 3 ms 2892 KB Output is correct
32 Correct 2 ms 2764 KB Output is correct
33 Correct 7 ms 4044 KB Output is correct
34 Correct 7 ms 4044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2508 KB Output is correct
2 Correct 1 ms 2508 KB Output is correct
3 Correct 2 ms 2508 KB Output is correct
4 Correct 1 ms 2508 KB Output is correct
5 Correct 2 ms 2508 KB Output is correct
6 Correct 2 ms 2508 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 2 ms 2508 KB Output is correct
9 Correct 1 ms 2508 KB Output is correct
10 Correct 2 ms 2508 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2508 KB Output is correct
13 Correct 2 ms 2508 KB Output is correct
14 Correct 2 ms 2584 KB Output is correct
15 Correct 3 ms 2636 KB Output is correct
16 Correct 3 ms 2564 KB Output is correct
17 Correct 3 ms 2764 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2508 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2508 KB Output is correct
22 Correct 2 ms 2508 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 3 ms 2636 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2508 KB Output is correct
28 Correct 3 ms 2764 KB Output is correct
29 Correct 5 ms 3304 KB Output is correct
30 Correct 3 ms 2764 KB Output is correct
31 Correct 3 ms 2892 KB Output is correct
32 Correct 3 ms 2764 KB Output is correct
33 Correct 8 ms 4044 KB Output is correct
34 Correct 7 ms 4040 KB Output is correct
35 Correct 26 ms 4712 KB Output is correct
36 Correct 5 ms 2892 KB Output is correct
37 Correct 22 ms 5356 KB Output is correct
38 Correct 35 ms 5640 KB Output is correct
39 Correct 29 ms 5708 KB Output is correct
40 Correct 31 ms 5564 KB Output is correct
41 Correct 33 ms 5572 KB Output is correct
42 Correct 17 ms 2532 KB Output is correct
43 Correct 13 ms 2532 KB Output is correct
44 Correct 14 ms 2636 KB Output is correct
45 Correct 31 ms 8388 KB Output is correct
46 Correct 30 ms 8396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2508 KB Output is correct
2 Correct 2 ms 2508 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 2 ms 2508 KB Output is correct
5 Correct 2 ms 2508 KB Output is correct
6 Correct 1 ms 2508 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 2 ms 2508 KB Output is correct
9 Correct 2 ms 2508 KB Output is correct
10 Correct 2 ms 2508 KB Output is correct
11 Correct 4 ms 2636 KB Output is correct
12 Correct 2 ms 2508 KB Output is correct
13 Correct 2 ms 2508 KB Output is correct
14 Correct 4 ms 2664 KB Output is correct
15 Correct 3 ms 2636 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 3 ms 2764 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2508 KB Output is correct
20 Correct 3 ms 2636 KB Output is correct
21 Correct 2 ms 2508 KB Output is correct
22 Correct 2 ms 2508 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 4 ms 2636 KB Output is correct
26 Correct 3 ms 2636 KB Output is correct
27 Correct 3 ms 2508 KB Output is correct
28 Correct 3 ms 2764 KB Output is correct
29 Correct 4 ms 3276 KB Output is correct
30 Correct 2 ms 2764 KB Output is correct
31 Correct 3 ms 2896 KB Output is correct
32 Correct 3 ms 2768 KB Output is correct
33 Correct 8 ms 4052 KB Output is correct
34 Correct 9 ms 4044 KB Output is correct
35 Correct 33 ms 4764 KB Output is correct
36 Correct 5 ms 2892 KB Output is correct
37 Correct 21 ms 5412 KB Output is correct
38 Correct 35 ms 5568 KB Output is correct
39 Correct 35 ms 5700 KB Output is correct
40 Correct 28 ms 5576 KB Output is correct
41 Correct 27 ms 5688 KB Output is correct
42 Correct 12 ms 2636 KB Output is correct
43 Correct 19 ms 2536 KB Output is correct
44 Correct 18 ms 2636 KB Output is correct
45 Correct 30 ms 8396 KB Output is correct
46 Correct 29 ms 8380 KB Output is correct
47 Correct 57 ms 12736 KB Output is correct
48 Correct 22 ms 5844 KB Output is correct
49 Correct 18 ms 5004 KB Output is correct
50 Correct 19 ms 4712 KB Output is correct
51 Correct 50 ms 7948 KB Output is correct
52 Correct 47 ms 8408 KB Output is correct
53 Correct 30 ms 5480 KB Output is correct
54 Correct 4 ms 3020 KB Output is correct
55 Correct 4 ms 3400 KB Output is correct
56 Correct 20 ms 4872 KB Output is correct
57 Correct 35 ms 11600 KB Output is correct
58 Correct 12 ms 3536 KB Output is correct
59 Correct 17 ms 3784 KB Output is correct
60 Correct 19 ms 4556 KB Output is correct
61 Correct 18 ms 3828 KB Output is correct
62 Correct 32 ms 9032 KB Output is correct
63 Correct 79 ms 26372 KB Output is correct
64 Correct 88 ms 29192 KB Output is correct
65 Correct 118 ms 39216 KB Output is correct
66 Correct 196 ms 67688 KB Output is correct
67 Correct 192 ms 67756 KB Output is correct