hiho week 310 register

Ended

Participants:33

Verdict:Accepted
Score:100 / 100
Submitted:2020-06-06 23:37:48

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        std::cin >> a[i];
    }
    int blockSize = static_cast<int>(std::sqrt(n));
    std::vector<int> step(n + 1);
    std::vector<int> nextBlock(n + 1);
    auto update = [&](int x)
    {
        int next = a[x] + x;
        if (next > n)
        {
            step[x] = 1;
            nextBlock[x] = -1;
        }
        else
        {
            int b = x / blockSize;
            if (next / blockSize != b)
            {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX