답안 #952522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952522 2024-03-24T07:32:25 Z Whisper 비밀 (JOI14_secret) C++17
0 / 100
381 ms 8380 KB
#include <bits/stdc++.h>
#include <secret.h>
using namespace std;
using ll = long long;

//#define int long long
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORD(i, a, b) for (int i = b; i >= a; i --)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPD(i, n) for (int i = n - 1; i >= 0; --i)

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)

constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//void setupIO(){
//    #define name "Whisper"
//    //Phu Trong from Nguyen Tat Thanh High School for gifted student
//    srand(time(NULL));
//    cin.tie(nullptr)->sync_with_stdio(false); cout.tie(nullptr);
//    freopen(name".inp", "r", stdin);
//    freopen(name".out", "w", stdout);
//    cout << fixed << setprecision(10);
//}

template <class X, class Y>
    bool minimize(X &x, const Y &y){
        X eps = 1e-9;
        if (x > y + eps) {x = y; return 1;}
        return 0;
    }

template <class X, class Y>
    bool maximize(X &x, const Y &y){
        X eps = 1e-9;
        if (x + eps < y) {x = y; return 1;}
        return 0;
    }
vector<int> a;
int nArr;
vector<vector<int>> sum;
//int Secret(int lx, int rx){
//    return (lx + rx);
//}
void dnc(int l, int r){
    if  (l == r){
        sum[l][l] = a[l];
        return;
    }
    if (l > r) return;
    int mid = (l + r) >> 1;

    sum[mid][mid] = a[mid];
    sum[mid + 1][mid + 1] = a[mid + 1];
    for (int i = mid - 1; i >= l; --i) sum[i][mid] = Secret(sum[i + 1][mid], a[i]);
    for (int i = mid + 2; i <= r; ++i) sum[mid + 1][i] = Secret(sum[mid + 1][i - 1], a[i]);
    dnc(l, mid - 1);
    dnc(mid + 1, r);
}
void Init(int N, int A[]){
    a.resize(N);
    sum.resize(N, vector<int>(N));
    nArr = N;
    for (int i = 0; i < N; ++i) a[i] = A[i];
    dnc(0, nArr - 1);
}
int Get(int l, int r, int u, int v){
    if (l > r) return 0;
    int mid = (l + r) >> 1;
    if (u <= mid && mid < v) return Secret(sum[u][mid], sum[mid + 1][v]);
    if (v <= mid)
        return Get(l, mid, u, v);
    return Get(mid + 1, r, u, v);
}

int Query(int l, int r){
    return (l == r ? a[l] : Get(0, nArr - 1, l, r));
}
//void Whisper(){
//    int a[8] = {1, 4, 7, 2, 5, 8, 3, 6};
//    Init(8, a);
//    cout << "CASE 1: " << Query(0, 3) << '\n';
//    cout << "CASE 2: " << Query(1, 7) << '\n';
//    cout << "CASE 3: " << Query(5, 5) << '\n';
//    cout << "CASE 4: " << Query(2, 4) << '\n';
//}
//
//
//signed main(){
//    setupIO();
//    int Test = 1;
////    cin >> Test;
//    for ( int i = 1 ; i <= Test ; i++ ){
//        Whisper();
//        if (i < Test) cout << '\n';
//    }
//}


# 결과 실행 시간 메모리 Grader output
1 Incorrect 101 ms 3756 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 96 ms 3772 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 96 ms 3676 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 379 ms 8284 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 381 ms 8360 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 356 ms 8276 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 361 ms 8368 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 379 ms 8360 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 363 ms 8380 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 359 ms 8268 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.