답안 #21975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
21975 2017-04-28T08:10:25 Z Hiasat Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
333 ms 113844 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;

const int MOD = 1e9 + 7;

const ll oo = 1e15;

typedef long long ll;

int n , m;

pii d[30010];

bitset<30010> vis[30010];

vector<int> dogs[30010];


int main() {
 	//freopen("input.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; ++i){
		scanf("%d%d",&d[i].first,&d[i].second);
		dogs[d[i].first].push_back(d[i].second);
	}
	for (int i = 1; i <= n; ++i){
		sort(dogs[i].begin(),dogs[i].end());
		dogs[i].resize(unique(dogs[i].begin(),dogs[i].end()) - dogs[i].begin());
	}
	deque< pair<int , pii > > q;
	vis[d[0].first][d[0].second] = 1;
	q.push_front(make_pair(0,make_pair(d[0].first,d[0].second)));
	while(!q.empty()){
		pair<int , pii > src = q.front();
		if(src.second.first == d[1].first){
			printf("%d\n", src.first);
			return 0;
		}
		q.pop_front();
		for (int i = 0; i < dogs[src.second.first].size(); ++i){
			int nw = dogs[src.second.first][i];
			if(vis[src.second.first][nw])
				continue;
			vis[src.second.first][nw] = 1;
			q.push_front(make_pair(src.first,make_pair(src.second.first,nw)));
		}
		for(int i = -1 ; i <= 1 ; i+= 2){
			int nw = src.second.first + src.second.second* i;
			if(nw < 0 || nw >= n)
				continue;
			if(vis[nw][src.second.second])
				continue;
			vis[nw][src.second.second]=1;
			q.push_back(make_pair(1 + src.first,make_pair(nw,src.second.second)));
		}
	}
	puts("-1");
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:48:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < dogs[src.second.first].size(); ++i){
                     ^
skyscraper.cpp:29:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
skyscraper.cpp:31:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&d[i].first,&d[i].second);
                                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 112920 KB Output is correct
2 Correct 0 ms 112920 KB Output is correct
3 Correct 0 ms 112920 KB Output is correct
4 Correct 0 ms 112920 KB Output is correct
5 Correct 0 ms 112920 KB Output is correct
6 Correct 0 ms 112920 KB Output is correct
7 Correct 0 ms 112920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 112920 KB Output is correct
2 Correct 0 ms 112920 KB Output is correct
3 Correct 0 ms 112920 KB Output is correct
4 Correct 0 ms 112920 KB Output is correct
5 Correct 0 ms 112920 KB Output is correct
6 Correct 0 ms 112920 KB Output is correct
7 Correct 0 ms 112920 KB Output is correct
8 Correct 0 ms 112920 KB Output is correct
9 Correct 0 ms 112920 KB Output is correct
10 Correct 0 ms 112920 KB Output is correct
11 Correct 0 ms 112920 KB Output is correct
12 Correct 0 ms 112920 KB Output is correct
13 Correct 0 ms 112920 KB Output is correct
14 Correct 0 ms 112920 KB Output is correct
15 Correct 0 ms 112920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 112920 KB Output is correct
2 Correct 0 ms 112920 KB Output is correct
3 Correct 0 ms 112920 KB Output is correct
4 Correct 0 ms 112920 KB Output is correct
5 Correct 0 ms 112920 KB Output is correct
6 Correct 0 ms 112920 KB Output is correct
7 Correct 0 ms 112920 KB Output is correct
8 Correct 0 ms 112920 KB Output is correct
9 Correct 0 ms 112920 KB Output is correct
10 Correct 0 ms 112920 KB Output is correct
11 Correct 0 ms 112920 KB Output is correct
12 Correct 0 ms 112920 KB Output is correct
13 Correct 0 ms 112920 KB Output is correct
14 Correct 0 ms 112920 KB Output is correct
15 Correct 0 ms 112920 KB Output is correct
16 Correct 0 ms 112920 KB Output is correct
17 Correct 0 ms 112920 KB Output is correct
18 Correct 0 ms 112920 KB Output is correct
19 Correct 0 ms 112920 KB Output is correct
20 Correct 0 ms 113052 KB Output is correct
21 Correct 0 ms 112920 KB Output is correct
22 Correct 0 ms 112920 KB Output is correct
23 Correct 3 ms 112920 KB Output is correct
24 Correct 3 ms 112920 KB Output is correct
25 Correct 0 ms 112920 KB Output is correct
26 Correct 3 ms 112920 KB Output is correct
27 Correct 0 ms 112920 KB Output is correct
28 Correct 6 ms 113052 KB Output is correct
29 Correct 6 ms 112920 KB Output is correct
30 Correct 0 ms 112920 KB Output is correct
31 Correct 0 ms 112920 KB Output is correct
32 Correct 0 ms 112920 KB Output is correct
33 Correct 3 ms 112920 KB Output is correct
34 Correct 3 ms 112920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 112920 KB Output is correct
2 Correct 0 ms 112920 KB Output is correct
3 Correct 0 ms 112920 KB Output is correct
4 Correct 0 ms 112920 KB Output is correct
5 Correct 0 ms 112920 KB Output is correct
6 Correct 0 ms 112920 KB Output is correct
7 Correct 0 ms 112920 KB Output is correct
8 Correct 0 ms 112920 KB Output is correct
9 Correct 0 ms 112920 KB Output is correct
10 Correct 0 ms 112920 KB Output is correct
11 Correct 0 ms 112920 KB Output is correct
12 Correct 0 ms 112920 KB Output is correct
13 Correct 0 ms 112920 KB Output is correct
14 Correct 0 ms 112920 KB Output is correct
15 Correct 0 ms 112920 KB Output is correct
16 Correct 0 ms 112920 KB Output is correct
17 Correct 3 ms 112920 KB Output is correct
18 Correct 0 ms 112920 KB Output is correct
19 Correct 0 ms 112920 KB Output is correct
20 Correct 0 ms 113052 KB Output is correct
21 Correct 0 ms 112920 KB Output is correct
22 Correct 0 ms 112920 KB Output is correct
23 Correct 0 ms 112920 KB Output is correct
24 Correct 0 ms 112920 KB Output is correct
25 Correct 0 ms 112920 KB Output is correct
26 Correct 3 ms 112920 KB Output is correct
27 Correct 0 ms 112920 KB Output is correct
28 Correct 6 ms 113052 KB Output is correct
29 Correct 3 ms 112920 KB Output is correct
30 Correct 3 ms 112920 KB Output is correct
31 Correct 0 ms 112920 KB Output is correct
32 Correct 3 ms 112920 KB Output is correct
33 Correct 0 ms 112920 KB Output is correct
34 Correct 0 ms 112920 KB Output is correct
35 Correct 13 ms 113316 KB Output is correct
36 Correct 0 ms 113052 KB Output is correct
37 Correct 6 ms 113316 KB Output is correct
38 Correct 13 ms 113456 KB Output is correct
39 Correct 9 ms 113184 KB Output is correct
40 Correct 13 ms 113184 KB Output is correct
41 Correct 9 ms 113184 KB Output is correct
42 Correct 9 ms 113196 KB Output is correct
43 Correct 6 ms 113196 KB Output is correct
44 Correct 9 ms 113192 KB Output is correct
45 Correct 43 ms 113448 KB Output is correct
46 Correct 29 ms 113448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 112920 KB Output is correct
2 Correct 0 ms 112920 KB Output is correct
3 Correct 0 ms 112920 KB Output is correct
4 Correct 0 ms 112920 KB Output is correct
5 Correct 0 ms 112920 KB Output is correct
6 Correct 0 ms 112920 KB Output is correct
7 Correct 0 ms 112920 KB Output is correct
8 Correct 0 ms 112920 KB Output is correct
9 Correct 0 ms 112920 KB Output is correct
10 Correct 0 ms 112920 KB Output is correct
11 Correct 0 ms 112920 KB Output is correct
12 Correct 0 ms 112920 KB Output is correct
13 Correct 0 ms 112920 KB Output is correct
14 Correct 0 ms 112920 KB Output is correct
15 Correct 0 ms 112920 KB Output is correct
16 Correct 0 ms 112920 KB Output is correct
17 Correct 0 ms 112920 KB Output is correct
18 Correct 0 ms 112920 KB Output is correct
19 Correct 0 ms 112920 KB Output is correct
20 Correct 0 ms 113052 KB Output is correct
21 Correct 0 ms 112920 KB Output is correct
22 Correct 0 ms 112920 KB Output is correct
23 Correct 3 ms 112920 KB Output is correct
24 Correct 0 ms 112920 KB Output is correct
25 Correct 0 ms 112920 KB Output is correct
26 Correct 0 ms 112920 KB Output is correct
27 Correct 0 ms 112920 KB Output is correct
28 Correct 3 ms 113052 KB Output is correct
29 Correct 6 ms 112920 KB Output is correct
30 Correct 0 ms 112920 KB Output is correct
31 Correct 6 ms 112920 KB Output is correct
32 Correct 3 ms 112920 KB Output is correct
33 Correct 6 ms 112920 KB Output is correct
34 Correct 3 ms 112920 KB Output is correct
35 Correct 16 ms 113316 KB Output is correct
36 Correct 3 ms 113052 KB Output is correct
37 Correct 16 ms 113316 KB Output is correct
38 Correct 16 ms 113456 KB Output is correct
39 Correct 3 ms 113184 KB Output is correct
40 Correct 13 ms 113184 KB Output is correct
41 Correct 16 ms 113184 KB Output is correct
42 Correct 9 ms 113196 KB Output is correct
43 Correct 3 ms 113196 KB Output is correct
44 Correct 6 ms 113192 KB Output is correct
45 Correct 39 ms 113448 KB Output is correct
46 Correct 29 ms 113448 KB Output is correct
47 Correct 16 ms 113448 KB Output is correct
48 Correct 9 ms 113448 KB Output is correct
49 Correct 13 ms 113448 KB Output is correct
50 Correct 6 ms 113316 KB Output is correct
51 Correct 33 ms 113580 KB Output is correct
52 Correct 53 ms 113580 KB Output is correct
53 Correct 6 ms 113580 KB Output is correct
54 Correct 13 ms 112920 KB Output is correct
55 Correct 9 ms 112920 KB Output is correct
56 Correct 26 ms 113844 KB Output is correct
57 Correct 3 ms 113052 KB Output is correct
58 Correct 33 ms 113192 KB Output is correct
59 Correct 19 ms 113192 KB Output is correct
60 Correct 29 ms 113200 KB Output is correct
61 Correct 36 ms 113208 KB Output is correct
62 Correct 59 ms 113844 KB Output is correct
63 Correct 146 ms 113448 KB Output is correct
64 Correct 136 ms 113316 KB Output is correct
65 Correct 186 ms 113448 KB Output is correct
66 Correct 333 ms 113448 KB Output is correct
67 Correct 179 ms 113444 KB Output is correct