Submission #61122

# Submission time Handle Problem Language Result Execution time Memory
61122 2018-07-25T08:25:09 Z Eae02 Boat (APIO16_boat) C++14
0 / 100
6 ms 756 KB
#include <bits/stdc++.h>

uint64_t PRIME = 1000000007;

std::vector<std::pair<uint64_t, uint64_t>> schools;

//std::unordered_map<uint64_t, uint64_t> memo[500];
//uint64_t memo[500][1000000000];

std::vector<uint64_t> memo[500];

uint64_t count(int i, uint64_t min)
{
	if (i >= schools.size())
		return 1;
	//auto mIt = memo[i].find(min);
	//if (mIt != memo[i].end())
	//	return mIt->second;
	
	if (memo[i][min] != 0)
		return memo[i][min] - 1;
	
	uint64_t c = count(i + 1, min);
	for (uint64_t n = std::max(schools[i].first, min == 0 ? 0 : (min + 1)); n <= schools[i].second; n++)
	{
		c = (c + count(i + 1, n)) % PRIME;
	}
	
	//memo[i].insert(std::make_pair(min, c));
	memo[i][min] = c + 1;
	return c;
}

int main()
{
	int N;
	std::cin >> N;
	
	uint64_t max2 = 0;
	
	schools.resize(N);
	for (int i = 0; i < N; i++)
	{
		std::cin >> schools[i].first;
		std::cin >> schools[i].second;
		max2 = std::max(max2, schools[i].second);
	}
	
	for (int i = 0; i < N; i++)
	{
		memo[i].resize(max2 + 1);
	}
	
	std::cout << (count(0, 0) - 1) << std::endl;
}

Compilation message

boat.cpp: In function 'uint64_t count(int, uint64_t)':
boat.cpp:14:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (i >= schools.size())
      ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 756 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -