# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144122 | emilem | Segway (COI19_segway) | C++14 | 874 ms | 1416 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |