Submission #144120

# Submission time Handle Problem Language Result Execution time Memory
144120 2019-08-16T06:56:42 Z emilem Segway (COI19_segway) C++14
15 / 100
826 ms 1144 KB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> speed(n), speed2(n), speed3(n);
	for (int i = 0; i < n; ++i)
		cin >> speed[i] >> speed2[i] >> speed3[i];
	int m;
	cin >> m;
	vector<bool> isPoint(300, false);
	vector<int> passed(300, 0);
	while (m--)
	{
		int i;
		cin >> i;
		isPoint[i] = true;
	}
	vector<int> ans(n, -1);
	vector<int> pos(n);
	vector<int> secInMove(n);
	vector<bool> boosted(n);
	vector<int> secInBoost(n);
	vector<int> maxSecInBoost(n);
	for (int sec = 1; ; ++sec)
	{
		int hasAnswered = 0;
		vector<int> addPassed;
		for (int rider = 0; rider < n; ++rider)
		{
			if (ans[rider] != -1)
				continue;
			++hasAnswered;
			++secInMove[rider];
			if (secInMove[rider] == (boosted[rider] ? 1 : speed[rider]))
			{
				if (boosted[rider] && secInBoost[rider] + 1 == maxSecInBoost[rider])
					boosted[rider] = false;
				else
					++secInBoost[rider];
				secInMove[rider] = 0;
				++pos[rider];
				if (pos[rider] == 100)
					speed[rider] = speed2[rider];
				else if (pos[rider] == 200)
					speed[rider] = speed3[rider];
				else if (pos[rider] == 300)
				{
					ans[rider] = sec;
					continue;
				}
				if (!boosted[rider] && isPoint[pos[rider]])
				{
					// cerr << "Rider " << rider << " at " << pos[rider] << endl;
					addPassed.push_back(pos[rider]);
					if (passed[pos[rider]] % 20)
					{
						boosted[rider] = true;
						secInBoost[rider] = 0;
						maxSecInBoost[rider] = passed[pos[rider]] % 20;
					}
				}
			}
		}
		if (!hasAnswered)
			break;
		for (int i = 0; i < addPassed.size(); ++i)
			++passed[addPassed[i]];
	}
	for (int rider = 0; rider < n; ++rider)
		cout << ans[rider] << '\n';

	char I;
	cin >> I;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:70:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < addPassed.size(); ++i)
                   ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 28 ms 376 KB Output is correct
4 Correct 111 ms 504 KB Output is correct
5 Correct 826 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 28 ms 376 KB Output is correct
4 Correct 111 ms 504 KB Output is correct
5 Correct 826 ms 1144 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -