Submission #1100935

# Submission time Handle Problem Language Result Execution time Memory
1100935 2024-10-15T04:28:29 Z doducanh Secret (JOI14_secret) C++14
100 / 100
313 ms 4680 KB
#include "secret.h"

#define LGN 10

unsigned y[LGN][1 << LGN];

void Init(int N, int A[])
{
    for (int s = LGN - 1, l = 1 << (LGN - 1); s >= 0; --s, l >>= 1)
        for (int i = 0; i + l < N; i += 2 * l)
        {
            int mid = i + l;
            y[s][mid] = A[mid];
            y[s][mid - 1] = A[mid - 1];
            for (int j = 1; j < l; ++j)
                y[s][mid - j - 1] = Secret(A[mid - j - 1], y[s][mid - j]);
            for (int j = 1; j < l && mid + j < N; ++j)
                y[s][mid + j] = Secret(y[s][mid + j - 1], A[mid + j]);
        }
}

int Query(int L, int R)
{
    if (L == R)
        return y[0][L];
    int i = LGN - 1, a = 0, b = 1 << LGN;
    while (i)
    {
        int mid = (a + b) / 2;
        if (R < mid)
            b = mid;
        else if (L >= mid)
            a = mid;
        else
            break;
        --i;
    }
    return Secret(y[i][L], y[i][R]);
}
# Verdict Execution time Memory Grader output
1 Correct 86 ms 3660 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 89 ms 3760 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 85 ms 3768 KB Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1
4 Correct 307 ms 4468 KB Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1
5 Correct 313 ms 4504 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
6 Correct 312 ms 4368 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
7 Correct 304 ms 4424 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
8 Correct 313 ms 4288 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
9 Correct 306 ms 4680 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
10 Correct 305 ms 4456 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1