답안 #342212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342212 2021-01-01T15:42:43 Z blue 비밀 (JOI14_secret) C++11
30 / 100
588 ms 4600 KB
#include "secret.h"
using namespace std;

int res[1000][11];

void Init(int N, int A[])
{
    for(int i = 0; i < N; i++) res[i][0] = A[i];

    for(int exp = 1; (1 << exp) <= N; exp++)
    {
        for(int i = 0; i + (1 << exp) - 1 < N; i++)
        {
            res[i][exp] = Secret(res[i][exp - 1], res[i + (1 << (exp-1))][exp - 1]);
        }
    }
}

int Query(int L, int R)
{
    int query_res = -1;
    int s = (R - L + 1);

    for(int exp = 10; exp >= 0; exp--)
    {
        if((R-L+1) & (1 << exp))
        {
            if(query_res == -1) query_res = res[L][exp];
            else query_res = Secret(query_res, res[L][exp]);

            L = L + (1 << exp);
        }
    }
    return query_res;
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:22:9: warning: unused variable 's' [-Wunused-variable]
   22 |     int s = (R - L + 1);
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 162 ms 2540 KB Output is partially correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 7
2 Partially correct 162 ms 2540 KB Output is partially correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 7
3 Partially correct 169 ms 2500 KB Output is partially correct - number of calls to Secret by Init = 3604, maximum number of calls to Secret by Query = 7
4 Partially correct 527 ms 4460 KB Output is partially correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 8
5 Partially correct 531 ms 4588 KB Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 8
6 Partially correct 508 ms 4492 KB Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 2
7 Partially correct 568 ms 4600 KB Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 8
8 Partially correct 539 ms 4460 KB Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 7
9 Partially correct 588 ms 4528 KB Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 8
10 Partially correct 539 ms 4460 KB Output is partially correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 7