Submission #108384

# Submission time Handle Problem Language Result Execution time Memory
108384 2019-04-29T03:07:32 Z nxteru Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
567 ms 50168 KB
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define B 200
struct t{
	int c,x,y;
};
int n,m,b[30005],p[30005];
vector<int>g[30005];
int vis[30005],d[30005][200],q[30005][200];
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
		scanf("%d%d",b+i,p+i);
		g[b[i]].PB(i);
	}
    for(int i=0;i<n;i++){
		vis[i]=-1;
		for(int j=0;j<B;j++)d[i][j]=-1;
	}
	for(int i=0;i<m;i++)for(int j=0;j<=n/B;j++)q[i][j]=-1;
	queue<t>bfs;
	bfs.push(t{0,b[0],0});
	while(!bfs.empty()){
		int c=bfs.front().c,x=bfs.front().x,y=bfs.front().y,z=(x-b[y]%p[y])/p[y];
		bfs.pop();
		if(x<0||n<=x)continue;
		if(vis[x]==-1){
			vis[x]=c;
			for(int i=0;i<g[x].size();i++){
				int u=g[x][i];
				bfs.push(t{c+1,x-p[u],u});
				bfs.push(t{c+1,x+p[u],u});
			}
		}
		if(p[y]<B&&d[x][p[y]]==-1){
			d[x][p[y]]=c;
			bfs.push(t{c+1,x-p[y],y});
			bfs.push(t{c+1,x+p[y],y});
		}
		if(p[y]>=B&&q[y][z]==-1){
			q[y][z]=c;
			bfs.push(t{c+1,x-p[y],y});
			bfs.push(t{c+1,x+p[y],y});
		}
	}
	printf("%d\n",vis[b[1]]);
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0;i<g[x].size();i++){
                ~^~~~~~~~~~~~
skyscraper.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",b+i,p+i);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 3 ms 1100 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 1152 KB Output is correct
7 Correct 4 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 3 ms 1152 KB Output is correct
9 Correct 2 ms 1152 KB Output is correct
10 Correct 4 ms 1536 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 4 ms 2816 KB Output is correct
13 Correct 4 ms 2688 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 3 ms 1152 KB Output is correct
9 Correct 2 ms 1152 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 5 ms 2688 KB Output is correct
13 Correct 4 ms 2688 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 4 ms 2816 KB Output is correct
16 Correct 4 ms 1920 KB Output is correct
17 Correct 7 ms 3172 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 5 ms 3072 KB Output is correct
20 Correct 7 ms 4352 KB Output is correct
21 Correct 4 ms 2304 KB Output is correct
22 Correct 4 ms 3072 KB Output is correct
23 Correct 5 ms 3072 KB Output is correct
24 Correct 6 ms 4096 KB Output is correct
25 Correct 8 ms 4224 KB Output is correct
26 Correct 7 ms 4224 KB Output is correct
27 Correct 8 ms 4340 KB Output is correct
28 Correct 8 ms 4352 KB Output is correct
29 Correct 11 ms 3328 KB Output is correct
30 Correct 6 ms 2816 KB Output is correct
31 Correct 6 ms 3200 KB Output is correct
32 Correct 5 ms 3072 KB Output is correct
33 Correct 9 ms 4352 KB Output is correct
34 Correct 10 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 3 ms 1152 KB Output is correct
10 Correct 3 ms 1472 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 5 ms 2816 KB Output is correct
13 Correct 5 ms 2688 KB Output is correct
14 Correct 4 ms 2816 KB Output is correct
15 Correct 6 ms 2816 KB Output is correct
16 Correct 3 ms 1920 KB Output is correct
17 Correct 5 ms 3200 KB Output is correct
18 Correct 6 ms 3200 KB Output is correct
19 Correct 6 ms 3072 KB Output is correct
20 Correct 8 ms 4224 KB Output is correct
21 Correct 4 ms 2304 KB Output is correct
22 Correct 5 ms 3072 KB Output is correct
23 Correct 5 ms 3072 KB Output is correct
24 Correct 7 ms 4096 KB Output is correct
25 Correct 6 ms 4224 KB Output is correct
26 Correct 7 ms 4224 KB Output is correct
27 Correct 6 ms 4224 KB Output is correct
28 Correct 11 ms 4224 KB Output is correct
29 Correct 7 ms 3200 KB Output is correct
30 Correct 5 ms 2816 KB Output is correct
31 Correct 7 ms 3072 KB Output is correct
32 Correct 5 ms 3072 KB Output is correct
33 Correct 13 ms 4352 KB Output is correct
34 Correct 11 ms 4352 KB Output is correct
35 Correct 39 ms 23296 KB Output is correct
36 Correct 9 ms 5760 KB Output is correct
37 Correct 44 ms 19044 KB Output is correct
38 Correct 42 ms 27384 KB Output is correct
39 Correct 43 ms 27384 KB Output is correct
40 Correct 42 ms 27392 KB Output is correct
41 Correct 41 ms 27356 KB Output is correct
42 Correct 27 ms 27264 KB Output is correct
43 Correct 28 ms 27128 KB Output is correct
44 Correct 29 ms 27132 KB Output is correct
45 Correct 53 ms 27896 KB Output is correct
46 Correct 79 ms 27904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1052 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 3 ms 1152 KB Output is correct
9 Correct 3 ms 1152 KB Output is correct
10 Correct 23 ms 1408 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 5 ms 2688 KB Output is correct
13 Correct 4 ms 2688 KB Output is correct
14 Correct 4 ms 2816 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
16 Correct 4 ms 1920 KB Output is correct
17 Correct 5 ms 3072 KB Output is correct
18 Correct 5 ms 3200 KB Output is correct
19 Correct 4 ms 3120 KB Output is correct
20 Correct 6 ms 4224 KB Output is correct
21 Correct 4 ms 2304 KB Output is correct
22 Correct 4 ms 3072 KB Output is correct
23 Correct 5 ms 3072 KB Output is correct
24 Correct 8 ms 4096 KB Output is correct
25 Correct 6 ms 4224 KB Output is correct
26 Correct 7 ms 4224 KB Output is correct
27 Correct 6 ms 4224 KB Output is correct
28 Correct 8 ms 4224 KB Output is correct
29 Correct 6 ms 3328 KB Output is correct
30 Correct 6 ms 2816 KB Output is correct
31 Correct 6 ms 3072 KB Output is correct
32 Correct 6 ms 3072 KB Output is correct
33 Correct 18 ms 4352 KB Output is correct
34 Correct 13 ms 4352 KB Output is correct
35 Correct 36 ms 23296 KB Output is correct
36 Correct 11 ms 5888 KB Output is correct
37 Correct 41 ms 18936 KB Output is correct
38 Correct 49 ms 27384 KB Output is correct
39 Correct 50 ms 27384 KB Output is correct
40 Correct 51 ms 27384 KB Output is correct
41 Correct 53 ms 27384 KB Output is correct
42 Correct 31 ms 27256 KB Output is correct
43 Correct 30 ms 27256 KB Output is correct
44 Correct 28 ms 27264 KB Output is correct
45 Correct 62 ms 28024 KB Output is correct
46 Correct 63 ms 27896 KB Output is correct
47 Correct 122 ms 31480 KB Output is correct
48 Correct 46 ms 37496 KB Output is correct
49 Correct 42 ms 38264 KB Output is correct
50 Correct 36 ms 35064 KB Output is correct
51 Correct 87 ms 49276 KB Output is correct
52 Correct 107 ms 49272 KB Output is correct
53 Correct 75 ms 48888 KB Output is correct
54 Correct 25 ms 24592 KB Output is correct
55 Correct 34 ms 24568 KB Output is correct
56 Correct 60 ms 49272 KB Output is correct
57 Correct 63 ms 26624 KB Output is correct
58 Correct 63 ms 49256 KB Output is correct
59 Correct 74 ms 49144 KB Output is correct
60 Correct 63 ms 49156 KB Output is correct
61 Correct 75 ms 49148 KB Output is correct
62 Correct 101 ms 49272 KB Output is correct
63 Correct 199 ms 49020 KB Output is correct
64 Correct 228 ms 49016 KB Output is correct
65 Correct 469 ms 49272 KB Output is correct
66 Correct 567 ms 50168 KB Output is correct
67 Correct 475 ms 50068 KB Output is correct