답안 #68368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68368 2018-08-16T20:46:51 Z thebes Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 97372 KB
#include <bits/stdc++.h>
using namespace std;

const int MN = 30004, MS = 180;
int N, M, S, i, j, src, des, x, y, ent[MN];
struct pir{int f, s, p;}; vector<pir> e[MN]; bitset<MS> pw[MN]; 
pir pr(int f, int s, int p){pir z={f,s,p}; return z;}
struct pq{bool operator()(const pir&i,const pir&j){return(i.s>j.s);}};
priority_queue<pir,vector<pir>,pq> q;

int main(){
	for(scanf("%d%d",&N,&M),S=sqrt(N+0.0);i<M;i++){
		scanf("%d%d",&x,&y);
		if(i == 0) src = x;
		else if(i == 1) des = x;
		if(y >= S){
			for(j=1;x-j*y>=0;j++)
				e[x].push_back(pr(x-j*y,j,-1));
			for(j=1;x+j*y<N;j++)
				e[x].push_back(pr(x+j*y,j,-1));
		}
		else e[x].push_back(pr(x,0,y));
	}
	pir st = {src, 0, -1}; q.push(st);
	while(!q.empty()){
		pir _ = q.top(); q.pop();
		if(_.f == des){printf("%d\n",_.s); return 0;}
		if(_.p == -1){
			if(ent[_.f]) continue;
			else ent[_.f] = 1;
			for(auto v : e[_.f]){
				if(v.p == -1 && !ent[v.f]) q.push(pr(v.f,v.s+_.s,v.p));
				else if(v.p != -1 && !pw[v.f][v.p]) q.push(pr(v.f,v.s+_.s,v.p));
			}
		}
		else{
			if(pw[_.f][_.p]) continue;
			else pw[_.f][_.p] = 1;
			if(!ent[_.f]) q.push(pr(_.f,_.s,-1));
			if(_.f+_.p < N && !pw[_.f+_.p][_.p]) q.push(pr(_.f+_.p,_.s+1,_.p));
			if(_.f-_.p >=0 && !pw[_.f-_.p][_.p]) q.push(pr(_.f-_.p,_.s+1,_.p));
		}
	}
	printf("-1\n");
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(scanf("%d%d",&N,&M),S=sqrt(N+0.0);i<M;i++){
      ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1144 KB Output is correct
2 Correct 3 ms 1260 KB Output is correct
3 Correct 3 ms 1356 KB Output is correct
4 Correct 3 ms 1468 KB Output is correct
5 Correct 3 ms 1468 KB Output is correct
6 Correct 3 ms 1508 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1512 KB Output is correct
2 Correct 3 ms 1536 KB Output is correct
3 Correct 3 ms 1604 KB Output is correct
4 Correct 3 ms 1604 KB Output is correct
5 Correct 3 ms 1604 KB Output is correct
6 Correct 3 ms 1604 KB Output is correct
7 Correct 3 ms 1612 KB Output is correct
8 Correct 3 ms 1612 KB Output is correct
9 Correct 2 ms 1612 KB Output is correct
10 Correct 4 ms 1612 KB Output is correct
11 Correct 4 ms 1736 KB Output is correct
12 Correct 3 ms 1736 KB Output is correct
13 Correct 3 ms 1740 KB Output is correct
14 Correct 3 ms 1772 KB Output is correct
15 Correct 3 ms 1780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1780 KB Output is correct
2 Correct 3 ms 1780 KB Output is correct
3 Correct 3 ms 1780 KB Output is correct
4 Correct 2 ms 1780 KB Output is correct
5 Correct 3 ms 1780 KB Output is correct
6 Correct 3 ms 1780 KB Output is correct
7 Correct 3 ms 1780 KB Output is correct
8 Correct 4 ms 1780 KB Output is correct
9 Correct 3 ms 1780 KB Output is correct
10 Correct 4 ms 1780 KB Output is correct
11 Correct 3 ms 1832 KB Output is correct
12 Correct 3 ms 1832 KB Output is correct
13 Correct 4 ms 1856 KB Output is correct
14 Correct 4 ms 2012 KB Output is correct
15 Correct 4 ms 2012 KB Output is correct
16 Correct 3 ms 2012 KB Output is correct
17 Correct 4 ms 2044 KB Output is correct
18 Correct 3 ms 2044 KB Output is correct
19 Correct 3 ms 2044 KB Output is correct
20 Correct 4 ms 2044 KB Output is correct
21 Correct 3 ms 2044 KB Output is correct
22 Correct 3 ms 2044 KB Output is correct
23 Correct 3 ms 2044 KB Output is correct
24 Correct 4 ms 2216 KB Output is correct
25 Correct 5 ms 2216 KB Output is correct
26 Correct 6 ms 2216 KB Output is correct
27 Correct 4 ms 2216 KB Output is correct
28 Correct 4 ms 2216 KB Output is correct
29 Correct 7 ms 2216 KB Output is correct
30 Correct 6 ms 2216 KB Output is correct
31 Correct 6 ms 2248 KB Output is correct
32 Correct 5 ms 2508 KB Output is correct
33 Correct 17 ms 3676 KB Output is correct
34 Correct 15 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3676 KB Output is correct
2 Correct 3 ms 3676 KB Output is correct
3 Correct 3 ms 3676 KB Output is correct
4 Correct 3 ms 3676 KB Output is correct
5 Correct 3 ms 3676 KB Output is correct
6 Correct 2 ms 3676 KB Output is correct
7 Correct 2 ms 3676 KB Output is correct
8 Correct 3 ms 3676 KB Output is correct
9 Correct 3 ms 3676 KB Output is correct
10 Correct 3 ms 3676 KB Output is correct
11 Correct 4 ms 3676 KB Output is correct
12 Correct 3 ms 3676 KB Output is correct
13 Correct 3 ms 3676 KB Output is correct
14 Correct 3 ms 3676 KB Output is correct
15 Correct 4 ms 3676 KB Output is correct
16 Correct 4 ms 3676 KB Output is correct
17 Correct 4 ms 3676 KB Output is correct
18 Correct 3 ms 3676 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 3 ms 3676 KB Output is correct
21 Correct 3 ms 3676 KB Output is correct
22 Correct 3 ms 3676 KB Output is correct
23 Correct 4 ms 3676 KB Output is correct
24 Correct 4 ms 3676 KB Output is correct
25 Correct 4 ms 3676 KB Output is correct
26 Correct 3 ms 3676 KB Output is correct
27 Correct 4 ms 3676 KB Output is correct
28 Correct 5 ms 3676 KB Output is correct
29 Correct 8 ms 3676 KB Output is correct
30 Correct 5 ms 3676 KB Output is correct
31 Correct 6 ms 3676 KB Output is correct
32 Correct 8 ms 3676 KB Output is correct
33 Correct 23 ms 3984 KB Output is correct
34 Correct 13 ms 3984 KB Output is correct
35 Correct 14 ms 4136 KB Output is correct
36 Correct 5 ms 4136 KB Output is correct
37 Correct 17 ms 5804 KB Output is correct
38 Correct 21 ms 5804 KB Output is correct
39 Correct 16 ms 5804 KB Output is correct
40 Correct 16 ms 5804 KB Output is correct
41 Correct 18 ms 6540 KB Output is correct
42 Correct 9 ms 6540 KB Output is correct
43 Correct 9 ms 6540 KB Output is correct
44 Correct 9 ms 6540 KB Output is correct
45 Correct 83 ms 16812 KB Output is correct
46 Correct 67 ms 17040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 17040 KB Output is correct
2 Correct 3 ms 17040 KB Output is correct
3 Correct 3 ms 17040 KB Output is correct
4 Correct 3 ms 17040 KB Output is correct
5 Correct 3 ms 17040 KB Output is correct
6 Correct 4 ms 17040 KB Output is correct
7 Correct 4 ms 17040 KB Output is correct
8 Correct 3 ms 17040 KB Output is correct
9 Correct 4 ms 17040 KB Output is correct
10 Correct 4 ms 17040 KB Output is correct
11 Correct 3 ms 17040 KB Output is correct
12 Correct 4 ms 17040 KB Output is correct
13 Correct 3 ms 17040 KB Output is correct
14 Correct 4 ms 17040 KB Output is correct
15 Correct 4 ms 17040 KB Output is correct
16 Correct 4 ms 17040 KB Output is correct
17 Correct 4 ms 17040 KB Output is correct
18 Correct 4 ms 17040 KB Output is correct
19 Correct 4 ms 17040 KB Output is correct
20 Correct 5 ms 17040 KB Output is correct
21 Correct 3 ms 17040 KB Output is correct
22 Correct 3 ms 17040 KB Output is correct
23 Correct 3 ms 17040 KB Output is correct
24 Correct 5 ms 17040 KB Output is correct
25 Correct 5 ms 17040 KB Output is correct
26 Correct 3 ms 17040 KB Output is correct
27 Correct 4 ms 17040 KB Output is correct
28 Correct 4 ms 17040 KB Output is correct
29 Correct 8 ms 17040 KB Output is correct
30 Correct 5 ms 17040 KB Output is correct
31 Correct 8 ms 17040 KB Output is correct
32 Correct 6 ms 17040 KB Output is correct
33 Correct 17 ms 17040 KB Output is correct
34 Correct 15 ms 17040 KB Output is correct
35 Correct 16 ms 17040 KB Output is correct
36 Correct 5 ms 17040 KB Output is correct
37 Correct 16 ms 17040 KB Output is correct
38 Correct 17 ms 17040 KB Output is correct
39 Correct 16 ms 17040 KB Output is correct
40 Correct 19 ms 17040 KB Output is correct
41 Correct 17 ms 17040 KB Output is correct
42 Correct 10 ms 17040 KB Output is correct
43 Correct 12 ms 17040 KB Output is correct
44 Correct 10 ms 17040 KB Output is correct
45 Correct 82 ms 19716 KB Output is correct
46 Correct 57 ms 19948 KB Output is correct
47 Correct 38 ms 19948 KB Output is correct
48 Correct 18 ms 19948 KB Output is correct
49 Correct 15 ms 19948 KB Output is correct
50 Correct 11 ms 19948 KB Output is correct
51 Correct 28 ms 19948 KB Output is correct
52 Correct 35 ms 19948 KB Output is correct
53 Correct 12 ms 19948 KB Output is correct
54 Correct 5 ms 19948 KB Output is correct
55 Correct 5 ms 19948 KB Output is correct
56 Correct 16 ms 19948 KB Output is correct
57 Correct 4 ms 19948 KB Output is correct
58 Correct 16 ms 19948 KB Output is correct
59 Correct 12 ms 19948 KB Output is correct
60 Correct 14 ms 19948 KB Output is correct
61 Correct 13 ms 19948 KB Output is correct
62 Correct 31 ms 19948 KB Output is correct
63 Correct 354 ms 58000 KB Output is correct
64 Correct 404 ms 71352 KB Output is correct
65 Correct 845 ms 81900 KB Output is correct
66 Execution timed out 1096 ms 97372 KB Time limit exceeded
67 Halted 0 ms 0 KB -