답안 #259241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259241 2020-08-07T12:49:23 Z shayan_p Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
432 ms 112760 KB
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 3e4 + 10;

vector<int> vec[maxn];
bitset<maxn> bs[maxn];
int dis[maxn];
bool done[maxn];
pii p[maxn];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++){
	cin >> p[i].F >> p[i].S;
	vec[p[i].F].PB(p[i].S);
    }
    fill(dis, dis + maxn, -1);
    deque< pair<pii, int> > q;
    q.push_back({p[0], 0});
    while(sz(q)){
	int pos = q.front().F.F, p = q.front().F.S, d = q.front().S;
	q.pop_front();
	if(bs[pos][p])
	    continue;
	bs[pos][p] = 1;
	if(done[pos] == 0){
	    dis[pos] = d;
	    for(int x : vec[pos])
		q.push_front({ {pos, x}, d });
	}
	done[pos] = 1;
	if(pos >= p)
	    q.push_back({ {pos - p, p}, d + 1 });
	if(pos + p < n)
	    q.push_back({ {pos + p, p}, d + 1 });
    }
    return cout << dis[p[1].F] << endl, 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1408 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 2 ms 1536 KB Output is correct
11 Correct 2 ms 1664 KB Output is correct
12 Correct 1 ms 1536 KB Output is correct
13 Correct 2 ms 1536 KB Output is correct
14 Correct 2 ms 1664 KB Output is correct
15 Correct 2 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 2 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 2 ms 1280 KB Output is correct
9 Correct 2 ms 1408 KB Output is correct
10 Correct 1 ms 1536 KB Output is correct
11 Correct 2 ms 1664 KB Output is correct
12 Correct 2 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 2 ms 1620 KB Output is correct
15 Correct 3 ms 1664 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 4 ms 3968 KB Output is correct
18 Correct 1 ms 1280 KB Output is correct
19 Correct 1 ms 1280 KB Output is correct
20 Correct 8 ms 8576 KB Output is correct
21 Correct 2 ms 1280 KB Output is correct
22 Correct 1 ms 1280 KB Output is correct
23 Correct 6 ms 6912 KB Output is correct
24 Correct 7 ms 8192 KB Output is correct
25 Correct 7 ms 8576 KB Output is correct
26 Correct 7 ms 8576 KB Output is correct
27 Correct 7 ms 8576 KB Output is correct
28 Correct 8 ms 8576 KB Output is correct
29 Correct 8 ms 8576 KB Output is correct
30 Correct 7 ms 8576 KB Output is correct
31 Correct 9 ms 8576 KB Output is correct
32 Correct 7 ms 8576 KB Output is correct
33 Correct 11 ms 8576 KB Output is correct
34 Correct 11 ms 8576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1280 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 1 ms 1536 KB Output is correct
11 Correct 2 ms 1536 KB Output is correct
12 Correct 1 ms 1536 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 2 ms 1664 KB Output is correct
15 Correct 2 ms 1664 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 4 ms 3968 KB Output is correct
18 Correct 1 ms 1280 KB Output is correct
19 Correct 1 ms 1280 KB Output is correct
20 Correct 6 ms 8576 KB Output is correct
21 Correct 1 ms 1152 KB Output is correct
22 Correct 1 ms 1280 KB Output is correct
23 Correct 5 ms 6912 KB Output is correct
24 Correct 7 ms 8192 KB Output is correct
25 Correct 7 ms 8576 KB Output is correct
26 Correct 7 ms 8576 KB Output is correct
27 Correct 7 ms 8576 KB Output is correct
28 Correct 7 ms 8580 KB Output is correct
29 Correct 9 ms 8576 KB Output is correct
30 Correct 7 ms 8576 KB Output is correct
31 Correct 7 ms 8576 KB Output is correct
32 Correct 8 ms 8576 KB Output is correct
33 Correct 12 ms 8576 KB Output is correct
34 Correct 11 ms 8576 KB Output is correct
35 Correct 17 ms 7296 KB Output is correct
36 Correct 5 ms 5280 KB Output is correct
37 Correct 19 ms 9344 KB Output is correct
38 Correct 19 ms 9600 KB Output is correct
39 Correct 20 ms 9600 KB Output is correct
40 Correct 19 ms 9600 KB Output is correct
41 Correct 19 ms 9600 KB Output is correct
42 Correct 13 ms 9336 KB Output is correct
43 Correct 13 ms 9332 KB Output is correct
44 Correct 11 ms 9344 KB Output is correct
45 Correct 29 ms 9856 KB Output is correct
46 Correct 32 ms 9848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1280 KB Output is correct
9 Correct 2 ms 1408 KB Output is correct
10 Correct 2 ms 1536 KB Output is correct
11 Correct 2 ms 1664 KB Output is correct
12 Correct 2 ms 1536 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 2 ms 1664 KB Output is correct
15 Correct 2 ms 1664 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 4 ms 3968 KB Output is correct
18 Correct 1 ms 1280 KB Output is correct
19 Correct 1 ms 1280 KB Output is correct
20 Correct 7 ms 8576 KB Output is correct
21 Correct 1 ms 1152 KB Output is correct
22 Correct 1 ms 1152 KB Output is correct
23 Correct 6 ms 6912 KB Output is correct
24 Correct 7 ms 8192 KB Output is correct
25 Correct 8 ms 8576 KB Output is correct
26 Correct 7 ms 8576 KB Output is correct
27 Correct 7 ms 8576 KB Output is correct
28 Correct 7 ms 8576 KB Output is correct
29 Correct 8 ms 8608 KB Output is correct
30 Correct 7 ms 8576 KB Output is correct
31 Correct 7 ms 8576 KB Output is correct
32 Correct 7 ms 8576 KB Output is correct
33 Correct 11 ms 8576 KB Output is correct
34 Correct 19 ms 8532 KB Output is correct
35 Correct 14 ms 7168 KB Output is correct
36 Correct 9 ms 5248 KB Output is correct
37 Correct 25 ms 9208 KB Output is correct
38 Correct 23 ms 9472 KB Output is correct
39 Correct 19 ms 9472 KB Output is correct
40 Correct 19 ms 9472 KB Output is correct
41 Correct 19 ms 9472 KB Output is correct
42 Correct 12 ms 9208 KB Output is correct
43 Correct 11 ms 9204 KB Output is correct
44 Correct 12 ms 9216 KB Output is correct
45 Correct 28 ms 9728 KB Output is correct
46 Correct 28 ms 9720 KB Output is correct
47 Correct 81 ms 47864 KB Output is correct
48 Correct 7 ms 1792 KB Output is correct
49 Correct 7 ms 1792 KB Output is correct
50 Correct 5 ms 1664 KB Output is correct
51 Correct 125 ms 112376 KB Output is correct
52 Correct 117 ms 112504 KB Output is correct
53 Correct 99 ms 112120 KB Output is correct
54 Correct 41 ms 61432 KB Output is correct
55 Correct 52 ms 78072 KB Output is correct
56 Correct 89 ms 112504 KB Output is correct
57 Correct 108 ms 111480 KB Output is correct
58 Correct 81 ms 111980 KB Output is correct
59 Correct 99 ms 111984 KB Output is correct
60 Correct 99 ms 111984 KB Output is correct
61 Correct 97 ms 111992 KB Output is correct
62 Correct 150 ms 112552 KB Output is correct
63 Correct 191 ms 112232 KB Output is correct
64 Correct 225 ms 112376 KB Output is correct
65 Correct 297 ms 112712 KB Output is correct
66 Correct 425 ms 112632 KB Output is correct
67 Correct 432 ms 112760 KB Output is correct