Submission #586921

# Submission time Handle Problem Language Result Execution time Memory
586921 2022-07-01T04:11:08 Z eecs Segway (COI19_segway) C++17
100 / 100
235 ms 32968 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 20010;
int n, m, cur[maxn], res[maxn], rem[maxn];
bool mark[maxn];
array<int, 3> speed[maxn];
vector<int> ev[maxn];

namespace BIT {
int c[310];

void add(int p, int v) {
    for (p++; p <= 300; p += p & -p) c[p] += v;
}

int sum(int p) {
    int s = 0;
    for (p++; p; p -= p & -p) s += c[p];
    return s;
}
} // namespace BIT

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int &x : speed[i]) cin >> x;
        ev[0].push_back(i);
    }
    cin >> m;
    while (m--) {
        int x;
        cin >> x, mark[x] = 1;
    }
    BIT::add(0, n);
    for (int i = 0; i < maxn; i++) {
        for (int j : ev[i]) {
            if (cur[j] == 300) { res[j] = i; continue; }
            if (!rem[j] && mark[cur[j]]) {
                rem[j] = (n - BIT::sum(cur[j])) % 20;
            }
            if (rem[j]) {
                ev[i + 1].push_back(j), rem[j]--;
            } else {
                ev[i + speed[j][cur[j] / 100]].push_back(j);
            }
        }
        for (int j : ev[i]) if (cur[j] < 300) {
            BIT::add(cur[j], -1), BIT::add(++cur[j], 1);
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << res[i] << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 4 ms 1192 KB Output is correct
3 Correct 10 ms 2260 KB Output is correct
4 Correct 38 ms 6052 KB Output is correct
5 Correct 235 ms 32968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
8 Correct 4 ms 1108 KB Output is correct
9 Correct 4 ms 1236 KB Output is correct
10 Correct 5 ms 1364 KB Output is correct
11 Correct 4 ms 1176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 4 ms 1192 KB Output is correct
3 Correct 10 ms 2260 KB Output is correct
4 Correct 38 ms 6052 KB Output is correct
5 Correct 235 ms 32968 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 2 ms 852 KB Output is correct
12 Correct 3 ms 1016 KB Output is correct
13 Correct 4 ms 1108 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 5 ms 1364 KB Output is correct
16 Correct 4 ms 1176 KB Output is correct
17 Correct 15 ms 2592 KB Output is correct
18 Correct 17 ms 4248 KB Output is correct
19 Correct 80 ms 14712 KB Output is correct
20 Correct 121 ms 19732 KB Output is correct
21 Correct 142 ms 23356 KB Output is correct
22 Correct 165 ms 28196 KB Output is correct
23 Correct 137 ms 26184 KB Output is correct