답안 #656565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
656565 2022-11-08T01:15:12 Z socpite 비밀 (JOI14_secret) C++14
0 / 100
20000 ms 4468 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;

#define f first
#define s second

typedef long long ll;

const int maxn = 1005;
vector<int> pfx[4*maxn], sfx[4*maxn];
int arr[maxn];

int n;

void build(int l, int r, int id){
    if(r-l<=1)return;
    int mid = (l+r)>>1;
    pfx[id].resize(r-mid);
    sfx[id].resize(mid+1-l);
    pfx[id][0]=arr[mid+1];
    sfx[id][0]=arr[mid];
    for(int i = mid+2; i <= r; i++){
        pfx[id][i-mid-1]=Secret(pfx[id][i-mid-2], arr[i]);
    }
    for(int i = 1; i < sfx[id].size(); i++){
        sfx[id][i]=Secret(arr[mid-i], sfx[id][i-1]);
    }
    build(l, mid, id<<1);
    build(mid+1, r, id<<1|1);
}

int gt(int l, int r, int ql, int qr, int id){
    int mid = (l+r)>>1;
    if(qr < mid)return gt(l, r, ql, qr, id<<1);
    else if(ql > mid+1)return gt(mid+1, r, ql, qr, id<<1|1);
    else{
        int re = -1;
        if(ql <= mid)re = sfx[id][mid-ql];
        if(qr >= mid+1){
            if(re < 0)re = pfx[id][qr-mid-1];
            else re = Secret(re, pfx[id][qr-mid-1]);
        }
        return re;
    }
}

int Query(int L, int R){
    if(L==R)return arr[L];
    else if(R-1==L)return Secret(arr[L], arr[R]);
    else return gt(0, n-1, L, R, 1);
}

void Init(int N, int A[]){
    n = N;
    for(int i = 0; i < n; i++)arr[i]=A[i];
    build(0, n-1, 1);
}

Compilation message

secret.cpp: In function 'void build(int, int, int)':
secret.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 1; i < sfx[id].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20096 ms 2540 KB Time limit exceeded
2 Execution timed out 20044 ms 2544 KB Time limit exceeded
3 Execution timed out 20032 ms 2464 KB Time limit exceeded
4 Execution timed out 20065 ms 4468 KB Time limit exceeded
5 Execution timed out 20089 ms 4440 KB Time limit exceeded
6 Execution timed out 20093 ms 4412 KB Time limit exceeded
7 Correct 436 ms 4452 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 424 ms 4468 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 433 ms 4428 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 422 ms 4428 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1