답안 #624471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
624471 2022-08-08T10:08:25 Z erto 비밀 (JOI14_secret) C++17
0 / 100
511 ms 8244 KB
#include "secret.h"
#include <bits/stdc++.h>
typedef long long int ll;
#define INF 1000000007
#define INF2 998244353
//#define N (ll)(2e5+ 5)
using namespace std;
 
int n;
int ans[1005][1005];
 
void calc(int lb, int rb, int A[]){
    int mid = (lb + rb) / 2;
    
    ans[mid][mid] = A[mid - 1];
    if(lb == rb)return;
 
    for(int i=mid - 1; i>=lb; i--){
        ans[mid][i] = Secret(A[i - 1], ans[mid][i + 1]);
    }
    ans[mid + 1][mid + 1] = A[mid];
    for(int i=mid + 2; i<=rb; i++){
        ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], A[i - 1]);
    }
 
    calc(lb, mid, A);
    calc(mid + 1, rb, A);
}
 
void Init(int N, int A[]){
    n = N;
    calc(1, n, A);
}
 
int Query(int L, int R){
    L++;
    R++;
    int a = 1, b = n;
    if(L == R)return ans[L - 1][L - 1];
    else{
        while(a < b){
            int mid = (a + b) / 2;
            if(L <= mid && mid < R){
                return Secret(ans[mid][L], ans[mid + 1][R]);
            }
            else if(mid == R){
                return ans[mid][L];
            }
            else if(mid < L){
                a = mid + 1; 
            }
            else{
                b = mid;
            }
        }
    }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 115 ms 4272 KB Wrong Answer: Query(56, 56) - expected : 677274107, actual : 535298575.
2 Incorrect 132 ms 4368 KB Wrong Answer: Query(389, 389) - expected : 472506730, actual : 473510552.
3 Incorrect 116 ms 4332 KB Wrong Answer: Query(18, 18) - expected : 238214183, actual : 951183855.
4 Incorrect 445 ms 8220 KB Wrong Answer: Query(788, 788) - expected : 937598145, actual : 562778496.
5 Incorrect 457 ms 8136 KB Wrong Answer: Query(957, 957) - expected : 115761809, actual : 414078098.
6 Incorrect 427 ms 8244 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 579799611.
7 Correct 445 ms 8140 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 432 ms 8240 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 511 ms 8220 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 452 ms 8140 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1