답안 #790483

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790483 2023-07-22T17:28:26 Z Andrey 비밀 (JOI14_secret) C++14
0 / 100
378 ms 4448 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;

int pr[1001][10];
int su[1001][10];

void Init(int n, int a[]) {
    for(int i = 0; i < n; i++) {
        pr[i][0] = a[i];
        su[i][0] = a[i];
    }
    for(int i = 1; i < 10; i++) {
        for(int j = 0; j < n; j++) {
            if(j%(1 << i) < (1 << (i-1))) {
                pr[j][i] = pr[j][i-1];
            }
            else {
                pr[j][i] = Secret(pr[j-1][i],a[j]);
            }
        }
    }
    for(int i = 1; i < 10; i++) {
        for(int j = n-1; j >= 0; j--) {
            if(su[j][i]%(1 << i) == 0) {
                su[j][i] = pr[min(n-1,j+(1 << i)-1)][i];
            }
            else {
                if(j%(1 << i) >= (1 << (i-1)) || j == n-1) {
                    su[j][i] = su[j][i-1];
                }
                else {
                    su[j][i] = Secret(a[j],su[j+1][i]);
                }
            }
        }
    }
}

int Query(int l, int r) {
    if(l == r) {
        return pr[l][0];
    }
    for(int i = 0; i < 10; i++) {
        if(l/(1 << (i+1)) == r/(1 << (i+1))) {
            return Secret(su[l][i],pr[r][i]);
        }
    }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 102 ms 2348 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 33635220.
2 Incorrect 106 ms 2388 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 696813705.
3 Incorrect 101 ms 2412 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 681629954.
4 Incorrect 378 ms 4448 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 843121162.
5 Incorrect 371 ms 4324 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 974144856.
6 Incorrect 375 ms 4348 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 174017973.
7 Incorrect 378 ms 4340 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 183210050.
8 Incorrect 377 ms 4356 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 891591128.
9 Incorrect 371 ms 4332 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 969153262.
10 Incorrect 372 ms 4328 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 74328451.