Submission #60468

# Submission time Handle Problem Language Result Execution time Memory
60468 2018-07-24T08:34:55 Z Eae02 Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 263168 KB
#include <bits/stdc++.h>

struct QEntry
{
	int building;
	int doge;
	int cost;
};

bool visited[30000][30000];

int main()
{
	int numBuildings, numDoges;
	std::cin >> numBuildings;
	std::cin >> numDoges;
	
	std::vector<std::vector<int>> dogesInBuildings(numBuildings);
	
	std::vector<int> dogePositions(numDoges);
	std::vector<int> dogePowers(numDoges);
	for (int i = 0; i < numDoges; i++)
	{
		std::cin >> dogePositions[i];
		std::cin >> dogePowers[i];
		
		dogesInBuildings[dogePositions[i]].push_back(i);
	}
	
	std::deque<QEntry> q;
	
	q.push_back(QEntry { dogePositions[0], 0, 0 });
	while (!q.empty())
	{
		QEntry entry = q.front();
		q.pop_front();
		
		if (visited[entry.building][entry.doge])
			continue;
		if (entry.doge == 1)
		{
			std::cout << entry.cost << std::endl;
			return 0;
		}
		
		visited[entry.building][entry.doge] = true;
		
		for (int d : dogesInBuildings[entry.building])
		{
			if (visited[entry.building][d])
				continue;
			q.push_front(QEntry { entry.building, d, entry.cost });
		}
		
		int pBuilding = entry.building - dogePowers[entry.doge];
		if (pBuilding >= 0 && !visited[pBuilding][entry.doge])
		{
			q.push_back(QEntry { pBuilding, entry.doge, entry.cost + 1 });
		}
		
		int nBuilding = entry.building + dogePowers[entry.doge];
		if (nBuilding < numBuildings && !visited[nBuilding][entry.doge])
		{
			q.push_back(QEntry { nBuilding, entry.doge, entry.cost + 1 });
		}
	}
	
	std::cout << "-1" << std::endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 6 ms 760 KB Output is correct
12 Correct 42 ms 25076 KB Output is correct
13 Correct 59 ms 25076 KB Output is correct
14 Correct 7 ms 25076 KB Output is correct
15 Correct 7 ms 25076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 25076 KB Output is correct
2 Correct 3 ms 25076 KB Output is correct
3 Correct 3 ms 25076 KB Output is correct
4 Correct 2 ms 25076 KB Output is correct
5 Correct 3 ms 25076 KB Output is correct
6 Correct 2 ms 25076 KB Output is correct
7 Correct 2 ms 25076 KB Output is correct
8 Correct 2 ms 25076 KB Output is correct
9 Correct 3 ms 25076 KB Output is correct
10 Correct 4 ms 25076 KB Output is correct
11 Correct 5 ms 25076 KB Output is correct
12 Correct 40 ms 25080 KB Output is correct
13 Correct 42 ms 25080 KB Output is correct
14 Correct 8 ms 25080 KB Output is correct
15 Correct 5 ms 25080 KB Output is correct
16 Correct 4 ms 25080 KB Output is correct
17 Correct 9 ms 25080 KB Output is correct
18 Correct 4 ms 25080 KB Output is correct
19 Correct 5 ms 25080 KB Output is correct
20 Correct 194 ms 25080 KB Output is correct
21 Correct 5 ms 25080 KB Output is correct
22 Correct 5 ms 25080 KB Output is correct
23 Correct 16 ms 25080 KB Output is correct
24 Correct 21 ms 25080 KB Output is correct
25 Correct 10 ms 25080 KB Output is correct
26 Correct 15 ms 25080 KB Output is correct
27 Correct 57 ms 29528 KB Output is correct
28 Correct 28 ms 29528 KB Output is correct
29 Correct 18 ms 29528 KB Output is correct
30 Correct 14 ms 29528 KB Output is correct
31 Correct 17 ms 29528 KB Output is correct
32 Correct 17 ms 29528 KB Output is correct
33 Correct 27 ms 29528 KB Output is correct
34 Correct 21 ms 29528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 29528 KB Output is correct
2 Correct 3 ms 29528 KB Output is correct
3 Correct 2 ms 29528 KB Output is correct
4 Correct 3 ms 29528 KB Output is correct
5 Correct 3 ms 29528 KB Output is correct
6 Correct 3 ms 29528 KB Output is correct
7 Correct 3 ms 29528 KB Output is correct
8 Correct 3 ms 29528 KB Output is correct
9 Correct 2 ms 29528 KB Output is correct
10 Correct 4 ms 29528 KB Output is correct
11 Correct 3 ms 29528 KB Output is correct
12 Correct 39 ms 29528 KB Output is correct
13 Correct 44 ms 29528 KB Output is correct
14 Correct 5 ms 29528 KB Output is correct
15 Correct 5 ms 29528 KB Output is correct
16 Correct 5 ms 29528 KB Output is correct
17 Correct 10 ms 29528 KB Output is correct
18 Correct 4 ms 29528 KB Output is correct
19 Correct 3 ms 29528 KB Output is correct
20 Correct 182 ms 29528 KB Output is correct
21 Correct 4 ms 29528 KB Output is correct
22 Correct 4 ms 29528 KB Output is correct
23 Correct 16 ms 29528 KB Output is correct
24 Correct 19 ms 29528 KB Output is correct
25 Correct 7 ms 29528 KB Output is correct
26 Correct 15 ms 29528 KB Output is correct
27 Correct 46 ms 29948 KB Output is correct
28 Correct 22 ms 29948 KB Output is correct
29 Correct 18 ms 29948 KB Output is correct
30 Correct 15 ms 29948 KB Output is correct
31 Correct 17 ms 29948 KB Output is correct
32 Correct 15 ms 29948 KB Output is correct
33 Correct 29 ms 29948 KB Output is correct
34 Correct 27 ms 29948 KB Output is correct
35 Correct 104 ms 40528 KB Output is correct
36 Correct 10 ms 40528 KB Output is correct
37 Correct 61 ms 40528 KB Output is correct
38 Correct 70 ms 40528 KB Output is correct
39 Correct 35 ms 40528 KB Output is correct
40 Correct 38 ms 40528 KB Output is correct
41 Correct 62 ms 40528 KB Output is correct
42 Correct 39 ms 40528 KB Output is correct
43 Execution timed out 1064 ms 263168 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -