Submission #40712

# Submission time Handle Problem Language Result Execution time Memory
40712 2018-02-06T22:46:08 Z IvanC Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
521 ms 38724 KB
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#define MAXN 2010
#define MP make_pair
using namespace std;
typedef pair<int,int> ii;
int grafo[MAXN][MAXN];
int origem,destino,n,m,processado[MAXN];
int main(){
	memset(grafo,-1,sizeof(grafo));
	scanf("%d %d",&n,&m);
	n--;
	for(int i=0;i<m;i++){
		int ini,percorre;
		scanf("%d %d",&ini,&percorre);
		if(i == 0) origem = ini;
		if(i == 1){
			destino = ini;
			continue;
		}
		for(int j = 1;ini - percorre*j >= 0;j++){
			if(grafo[ini][ini - percorre*j] == -1){
				grafo[ini][ini - percorre*j] = j;
			}
			else{
				grafo[ini][ini - percorre*j] = min(j,grafo[ini][ini - percorre*j]);
			}
		}
		for(int j = 1;ini + percorre*j <= n;j++){
			if(grafo[ini][ini + percorre*j] == -1){
				grafo[ini][ini + percorre*j] = j;
			}
			else{
				grafo[ini][ini + percorre*j] = min(j,grafo[ini][ini + percorre*j]);
			}
		}
	}
	priority_queue<ii, vector<ii> , greater<ii> > Dijkstra;
	Dijkstra.push(MP(0,origem));
	while(!Dijkstra.empty()){
		ii davez = Dijkstra.top();
		Dijkstra.pop();
		int v = davez.second, percorrido = davez.first;
		if(processado[v]) continue;
		processado[v] = 1;
		if(v == destino	){
			printf("%d\n",percorrido);
			return 0;
		}
		for(int i=0;i<=n;i++){
			if(!processado[i] && grafo[v][i] != -1){
				Dijkstra.push(MP(percorrido + grafo[v][i],i));
			}
		}
	}
	printf("-1\n");
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:13:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
                      ^
skyscraper.cpp:17:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&ini,&percorre);
                                ^
# Verdict Execution time Memory Grader output
1 Correct 12 ms 16120 KB Output is correct
2 Correct 13 ms 16228 KB Output is correct
3 Correct 12 ms 16228 KB Output is correct
4 Correct 14 ms 16376 KB Output is correct
5 Correct 12 ms 16376 KB Output is correct
6 Correct 12 ms 16376 KB Output is correct
7 Correct 12 ms 16380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 16384 KB Output is correct
2 Correct 12 ms 16388 KB Output is correct
3 Correct 13 ms 16520 KB Output is correct
4 Correct 12 ms 16520 KB Output is correct
5 Correct 12 ms 16520 KB Output is correct
6 Correct 12 ms 16520 KB Output is correct
7 Correct 13 ms 16520 KB Output is correct
8 Correct 12 ms 16520 KB Output is correct
9 Correct 13 ms 16524 KB Output is correct
10 Correct 13 ms 16528 KB Output is correct
11 Correct 13 ms 16536 KB Output is correct
12 Correct 13 ms 16544 KB Output is correct
13 Correct 14 ms 16700 KB Output is correct
14 Correct 14 ms 16700 KB Output is correct
15 Correct 14 ms 16700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 16700 KB Output is correct
2 Correct 12 ms 16700 KB Output is correct
3 Correct 13 ms 16792 KB Output is correct
4 Correct 12 ms 16792 KB Output is correct
5 Correct 12 ms 16792 KB Output is correct
6 Correct 12 ms 16792 KB Output is correct
7 Correct 14 ms 16792 KB Output is correct
8 Correct 13 ms 16792 KB Output is correct
9 Correct 13 ms 16792 KB Output is correct
10 Correct 13 ms 16792 KB Output is correct
11 Correct 14 ms 16792 KB Output is correct
12 Correct 14 ms 16792 KB Output is correct
13 Correct 14 ms 16792 KB Output is correct
14 Correct 14 ms 16820 KB Output is correct
15 Correct 14 ms 16820 KB Output is correct
16 Correct 13 ms 16820 KB Output is correct
17 Correct 15 ms 16892 KB Output is correct
18 Correct 14 ms 16892 KB Output is correct
19 Correct 14 ms 16892 KB Output is correct
20 Correct 428 ms 25200 KB Output is correct
21 Correct 13 ms 25200 KB Output is correct
22 Correct 12 ms 25200 KB Output is correct
23 Correct 18 ms 25200 KB Output is correct
24 Correct 20 ms 25200 KB Output is correct
25 Correct 15 ms 25200 KB Output is correct
26 Correct 21 ms 25200 KB Output is correct
27 Correct 22 ms 25200 KB Output is correct
28 Correct 25 ms 25200 KB Output is correct
29 Correct 22 ms 25200 KB Output is correct
30 Correct 24 ms 25200 KB Output is correct
31 Correct 20 ms 25200 KB Output is correct
32 Correct 19 ms 25200 KB Output is correct
33 Correct 26 ms 25200 KB Output is correct
34 Correct 27 ms 25200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 25200 KB Output is correct
2 Correct 13 ms 25200 KB Output is correct
3 Correct 13 ms 25200 KB Output is correct
4 Correct 13 ms 25200 KB Output is correct
5 Correct 13 ms 25200 KB Output is correct
6 Correct 13 ms 25200 KB Output is correct
7 Correct 13 ms 25200 KB Output is correct
8 Correct 13 ms 25200 KB Output is correct
9 Correct 13 ms 25200 KB Output is correct
10 Correct 13 ms 25200 KB Output is correct
11 Correct 13 ms 25200 KB Output is correct
12 Correct 13 ms 25200 KB Output is correct
13 Correct 14 ms 25200 KB Output is correct
14 Correct 13 ms 25200 KB Output is correct
15 Correct 15 ms 25200 KB Output is correct
16 Correct 13 ms 25200 KB Output is correct
17 Correct 15 ms 25200 KB Output is correct
18 Correct 13 ms 25200 KB Output is correct
19 Correct 13 ms 25200 KB Output is correct
20 Correct 415 ms 25476 KB Output is correct
21 Correct 13 ms 25476 KB Output is correct
22 Correct 13 ms 25476 KB Output is correct
23 Correct 18 ms 25476 KB Output is correct
24 Correct 20 ms 25476 KB Output is correct
25 Correct 16 ms 25476 KB Output is correct
26 Correct 24 ms 25476 KB Output is correct
27 Correct 22 ms 25476 KB Output is correct
28 Correct 19 ms 25476 KB Output is correct
29 Correct 22 ms 25476 KB Output is correct
30 Correct 21 ms 25476 KB Output is correct
31 Correct 20 ms 25476 KB Output is correct
32 Correct 21 ms 25476 KB Output is correct
33 Correct 27 ms 25476 KB Output is correct
34 Correct 29 ms 25476 KB Output is correct
35 Correct 29 ms 25476 KB Output is correct
36 Correct 15 ms 25476 KB Output is correct
37 Correct 35 ms 25476 KB Output is correct
38 Correct 28 ms 25476 KB Output is correct
39 Correct 23 ms 25476 KB Output is correct
40 Correct 28 ms 25476 KB Output is correct
41 Correct 28 ms 25476 KB Output is correct
42 Correct 92 ms 25476 KB Output is correct
43 Correct 96 ms 25476 KB Output is correct
44 Correct 504 ms 27796 KB Output is correct
45 Correct 74 ms 27796 KB Output is correct
46 Correct 66 ms 27796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 27796 KB Output is correct
2 Correct 13 ms 27796 KB Output is correct
3 Correct 13 ms 27796 KB Output is correct
4 Correct 13 ms 27796 KB Output is correct
5 Correct 12 ms 27796 KB Output is correct
6 Correct 13 ms 27796 KB Output is correct
7 Correct 14 ms 27796 KB Output is correct
8 Correct 15 ms 27796 KB Output is correct
9 Correct 13 ms 27796 KB Output is correct
10 Correct 13 ms 27796 KB Output is correct
11 Correct 14 ms 27796 KB Output is correct
12 Correct 13 ms 27796 KB Output is correct
13 Correct 15 ms 27796 KB Output is correct
14 Correct 14 ms 27796 KB Output is correct
15 Correct 13 ms 27796 KB Output is correct
16 Correct 14 ms 27796 KB Output is correct
17 Correct 15 ms 27796 KB Output is correct
18 Correct 13 ms 27796 KB Output is correct
19 Correct 16 ms 27796 KB Output is correct
20 Correct 411 ms 28476 KB Output is correct
21 Correct 13 ms 28476 KB Output is correct
22 Correct 13 ms 28476 KB Output is correct
23 Correct 19 ms 28476 KB Output is correct
24 Correct 22 ms 28476 KB Output is correct
25 Correct 15 ms 28476 KB Output is correct
26 Correct 22 ms 28476 KB Output is correct
27 Correct 23 ms 28476 KB Output is correct
28 Correct 21 ms 28476 KB Output is correct
29 Correct 22 ms 28476 KB Output is correct
30 Correct 20 ms 28476 KB Output is correct
31 Correct 21 ms 28476 KB Output is correct
32 Correct 20 ms 28476 KB Output is correct
33 Correct 28 ms 28476 KB Output is correct
34 Correct 25 ms 28476 KB Output is correct
35 Correct 29 ms 28476 KB Output is correct
36 Correct 15 ms 28476 KB Output is correct
37 Correct 28 ms 28476 KB Output is correct
38 Correct 27 ms 28476 KB Output is correct
39 Correct 23 ms 28476 KB Output is correct
40 Correct 23 ms 28476 KB Output is correct
41 Correct 25 ms 28476 KB Output is correct
42 Correct 96 ms 28476 KB Output is correct
43 Correct 96 ms 28476 KB Output is correct
44 Correct 521 ms 30796 KB Output is correct
45 Correct 75 ms 30796 KB Output is correct
46 Correct 65 ms 30796 KB Output is correct
47 Runtime error 27 ms 38724 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Halted 0 ms 0 KB -