답안 #144122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144122 2019-08-16T07:03:16 Z emilem Segway (COI19_segway) C++14
100 / 100
874 ms 1416 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] == maxSecInBoost[rider])
					boosted[rider] = false;
				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]])
				{
					// cerr << "Rider " << rider << " at " << pos[rider] << endl;
					addPassed.push_back(pos[rider]);
					if (!boosted[rider] && 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:68:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < addPassed.size(); ++i)
                   ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 28 ms 376 KB Output is correct
4 Correct 110 ms 504 KB Output is correct
5 Correct 874 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 10 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 28 ms 376 KB Output is correct
4 Correct 110 ms 504 KB Output is correct
5 Correct 874 ms 1016 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 10 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 35 ms 376 KB Output is correct
18 Correct 26 ms 376 KB Output is correct
19 Correct 171 ms 760 KB Output is correct
20 Correct 366 ms 860 KB Output is correct
21 Correct 301 ms 1076 KB Output is correct
22 Correct 374 ms 1272 KB Output is correct
23 Correct 198 ms 1416 KB Output is correct