답안 #643670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643670 2022-09-22T18:17:09 Z pls33 비밀 (JOI14_secret) C++17
0 / 100
480 ms 5688 KB
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;

#pragma region dalykai
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;
#pragma endregion

map<p32, int> queries;
vvi32 dst;

int leading_bit(int i)
{
    return 31 - __builtin_clz(i);
}

int secret_wrapper(int l, int r);

void Init(int n, int a[])
{
    dst = vvi32(leading_bit(n) + 1, vi32(n + 1));

    for (size_t row = 0; row < dst.size(); row++)
    {
        int length = 1 << row;

        for (int c = length; c < n + length; c += 2 * length)
        {
            for (int i = c + 1; i <= min(n, c + length); i++)
            {
                dst[row][i] = secret_wrapper(dst[row][i - 1], a[i - 1]);
            }

            for (int i = min(n, c) - 1; i >= c - length; i--)
            {
                dst[row][i] = secret_wrapper(a[i], dst[row][i + 1]);
            }
        }
    }
}

int Query(int l, int r)
{
    r++;
    int row = leading_bit(l ^ r);
    return secret_wrapper(dst[row][l], dst[row][r]);
}

int secret_wrapper(int l, int r)
{
    auto it = queries.find({l, r});

    int val = 0;
    if (it != queries.end())
    {
        val = it->second;
    }
    else
    {
        val = Secret(l, r);
        queries[{l, r}] = val;
    }

    return val;
}

Compilation message

secret.cpp:6: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
    6 | #pragma region dalykai
      | 
secret.cpp:29: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   29 | #pragma endregion
      |
# 결과 실행 시간 메모리 Grader output
1 Incorrect 116 ms 2624 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 34031537.
2 Incorrect 117 ms 2700 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 569483529.
3 Incorrect 114 ms 2636 KB Wrong Answer: Query(67, 224) - expected : 202440844, actual : 739311628.
4 Incorrect 422 ms 4824 KB Wrong Answer: Query(727, 872) - expected : 870334875, actual : 870334619.
5 Incorrect 441 ms 4916 KB Wrong Answer: Query(761, 790) - expected : 112945480, actual : 112871752.
6 Incorrect 422 ms 5004 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241.
7 Partially correct 480 ms 5508 KB Output isn't correct - number of calls to Secret by Init = 9992, maximum number of calls to Secret by Query = 1
8 Partially correct 432 ms 5524 KB Output isn't correct - number of calls to Secret by Init = 9992, maximum number of calls to Secret by Query = 1
9 Partially correct 443 ms 5688 KB Output isn't correct - number of calls to Secret by Init = 9992, maximum number of calls to Secret by Query = 1
10 Partially correct 431 ms 5452 KB Output isn't correct - number of calls to Secret by Init = 9992, maximum number of calls to Secret by Query = 1