Submission #366644

# Submission time Handle Problem Language Result Execution time Memory
366644 2021-02-14T20:14:12 Z idk321 Secret (JOI14_secret) C++11
0 / 100
624 ms 43692 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "secret.h"


const int N = 1000;
int* ar;
vector<int> need[N][N];

void cost(int a, int b)
{
    if (a == b)
    {
        need[a][b].push_back(ar[a]);
        return;
    } else if (a == b - 1)
    {
        need[a][a].push_back(ar[a]);
        need[b][b].push_back(ar[b]);
        need[a][b].push_back(ar[a]);
        need[a][b].push_back(ar[b]);
        return;
    } else if (b - a < 0) return;
    int mid = (a + b) / 2;
    int cur = ar[mid];
    need[mid][mid].push_back(cur);
    for (int i = mid - 1; i >= a; i--)
    {
        cur = Secret(cur, ar[i]);
        need[i][mid].push_back(cur);
    }
    cur = ar[mid + 1];
    need[mid + 1][mid + 1].push_back(cur);
    for (int i = mid + 2; i <= b; i++)
    {
        cur = Secret(cur, ar[i]);
        need[mid + 1][i].push_back(cur);
    }
    for (int i = mid; i >= a; i--)
    {
        for (int j = mid + 1; j <= b; j++)
        {
            need[i][j].push_back(need[i][mid][0]);
            need[i][j].push_back(need[mid + 1][j][0]);
        }
    }

    cost(a, mid - 1);
    cost(mid + 2, b);
}

/*
int main()
{

} */


void Init(int n, int A[])
{
    ar = A;
    cost(0, n - 1);
}

int Query(int l, int r)
{
    if (need[l][r].size() == 1) return need[l][r][0];
    int cur = Secret(need[l][r][0], need[l][r][1]);
    return cur;
}

# Verdict Execution time Memory Grader output
1 Incorrect 157 ms 30060 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 160 ms 30060 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 162 ms 30092 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 624 ms 43556 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 561 ms 43500 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184.
6 Incorrect 574 ms 43548 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192.
7 Incorrect 563 ms 43500 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 552 ms 43500 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 561 ms 43692 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 561 ms 43628 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.