Submission #144119

# Submission time Handle Problem Language Result Execution time Memory
144119 2019-08-16T06:46:09 Z emilem Segway (COI19_segway) C++14
0 / 100
3 ms 504 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 (isPoint[pos[rider]])
				{
					boosted[rider] = true;
					secInBoost[rider] = 0;
					maxSecInBoost[rider] = passed[pos[rider]] % 20;
					addPassed.push_back(pos[rider]);
				}
			}
		}
		if (!hasAnswered)
			break;
		for (int i = 0; i < addPassed.size(); ++i)
			++passed[addPassed[i]];
	}
	for (int rider = 0; rider < n; ++rider)
		cout << ans[rider] << ' ';
	cout << endl;

	char I;
	cin >> I;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:66: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 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -