/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Accepted 1ms 576.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 344.0 KiB
#7 Accepted 1ms 324.0 KiB
#8 Accepted 1ms 524.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 1ms 332.0 KiB
#11 Accepted 1ms 504.0 KiB
#12 Accepted 1ms 532.0 KiB
#13 Accepted 1ms 532.0 KiB
#14 Accepted 1ms 532.0 KiB
#15 Accepted 1ms 448.0 KiB
#16 Accepted 1ms 320.0 KiB
#17 Accepted 1ms 532.0 KiB
#18 Accepted 1ms 532.0 KiB
#19 Accepted 1ms 340.0 KiB
#20 Accepted 1ms 348.0 KiB
#21 Accepted 1ms 324.0 KiB
#22 Accepted 1ms 532.0 KiB
#23 Accepted 1ms 484.0 KiB
#24 Accepted 1ms 532.0 KiB
#25 Accepted 1ms 532.0 KiB
#26 Accepted 1ms 576.0 KiB
#27 Accepted 1ms 532.0 KiB
#28 Accepted 1ms 532.0 KiB
#29 Accepted 1ms 532.0 KiB
#30 Accepted 1ms 324.0 KiB
#31 Accepted 2ms 324.0 KiB
#32 Accepted 2ms 324.0 KiB
#33 Accepted 3ms 532.0 KiB
#34 Accepted 4ms 532.0 KiB
#35 Accepted 4ms 532.0 KiB
#36 Accepted 4ms 532.0 KiB
#37 Accepted 4ms 532.0 KiB
#38 Accepted 4ms 532.0 KiB
#39 Accepted 4ms 532.0 KiB
#40 Accepted 4ms 532.0 KiB
#41 Accepted 4ms 532.0 KiB
#42 Accepted 4ms 348.0 KiB
#43 Accepted 4ms 532.0 KiB
#44 Accepted 5ms 448.0 KiB
#45 Accepted 5ms 436.0 KiB
#46 Accepted 4ms 532.0 KiB
#47 Accepted 4ms 532.0 KiB
#48 Accepted 4ms 580.0 KiB
#49 Accepted 4ms 532.0 KiB
#50 Accepted 4ms 448.0 KiB
#51 Accepted 4ms 348.0 KiB
#52 Accepted 4ms 580.0 KiB
#53 Accepted 4ms 532.0 KiB
#54 Accepted 4ms 536.0 KiB
#55 Accepted 4ms 532.0 KiB
#56 Accepted 4ms 320.0 KiB
#57 Accepted 4ms 532.0 KiB
#58 Accepted 4ms 348.0 KiB
#59 Accepted 4ms 532.0 KiB
#60 Accepted 4ms 324.0 KiB
#61 Accepted 4ms 532.0 KiB
#62 Accepted 4ms 532.0 KiB
#63 Accepted 4ms 532.0 KiB
#64 Accepted 4ms 536.0 KiB
#65 Accepted 4ms 532.0 KiB
#66 Accepted 4ms 536.0 KiB
#67 Accepted 4ms 532.0 KiB
#68 Accepted 4ms 532.0 KiB
#69 Accepted 4ms 532.0 KiB
#70 Accepted 4ms 532.0 KiB
#71 Accepted 4ms 532.0 KiB
#72 Accepted 4ms 532.0 KiB
#73 Accepted 4ms 324.0 KiB
#74 Accepted 4ms 532.0 KiB
#75 Accepted 4ms 532.0 KiB
#76 Accepted 4ms 532.0 KiB
#77 Accepted 5ms 576.0 KiB
#78 Accepted 4ms 324.0 KiB
#79 Accepted 4ms 532.0 KiB
#80 Accepted 4ms 532.0 KiB
#81 Accepted 4ms 532.0 KiB
#82 Wrong Answer 4ms 532.0 KiB
#83 Wrong Answer 4ms 532.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long

const int N = 2e5+2;

int th_tree[4*N], roy_tree[4*N], a[N];

void build_th(int n,int b,int e,bool mn = 1) {
    if(b == e) {
        th_tree[n] = a[b];
        return;
    }
    int mid = (b + e) / 2;
    build_th(2*n,b,mid,!mn);
    build_th(2*n+1,mid+1,e,!mn);
    if(mn) th_tree[n] = min(th_tree[2*n],th_tree[2*n+1]);
    else th_tree[n] = max(th_tree[2*n],th_tree[2*n+1]);
}

void build_roy(int n,int b,int e,bool mx = 1) {
    if(b == e) {
        roy_tree[n] = a[b];
        return;
    }
    int mid = (b + e) / 2;
    build_roy(2*n,b,mid,!mx);
    build_roy(2*n+1,mid+1,e,!mx);
    if(!mx) roy_tree[n] = min(roy_tree[2*n],roy_tree[2*n+1]);
    else roy_tree[n] = max(roy_tree[2*n],roy_tree[2*n+1]);
}

void upd_th(int n,int b,int e,int idx,int v,bool mn = 1) {
    if(b == e) {
        th_tree[n] = v;
        return;
    }
    int mid = (b + e) / 2;
    if(idx <= mid) upd_th(2*n,b,mid,idx,v,!mn);
    else upd_th(2*n+1,mid+1,e,idx,v,!mn);
    if(mn) th_tree[n] = min(th_tree[2*n],th_tree[2*n+1]);
    else th_tree[n] = max(th_tree[2*n],th_tree[2*n+1]);
}

void upd_roy(int n,int b,int e,int idx,int v,bool mx = 1) {
    if(b == e) {
        roy_tree[n] = v;
        return;
    }
    int mid = (b + e) / 2;
    if(idx <= mid) upd_roy(2*n,b,mid,idx,v,!mx);
    else upd_roy(2*n+1,mid+1,e,idx,v,!mx);
    if(!mx) roy_tree[n] = min(roy_tree[2*n],roy_tree[2*n+1]);
    else roy_tree[n] = max(roy_tree[2*n],roy_tree[2*n+1]);
}

void solve() {
    int n,q;
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    build_th(1,1,n);
    build_roy(1,1,n);
    while(q--) {
        int i,v,p;
        cin >> i >> v >> p;
        upd_th(1,1,n,i,v);
        upd_roy(1,1,n,i,v);
        if(!p) cout << th_tree[1] << '\n';
        else cout << roy_tree[1] << '\n';
    }
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    // cin >> tc;
    for(int kase = 1; kase <= tc; kase++) {
        //cout << "Case " << kase << ": ";
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1169 Thakur vs Roy again
Contest
Brain Booster #9
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 17:28:53
Judged At
2025-04-06 17:28:53
Judged By
Score
81
Total Time
5ms
Peak Memory
580.0 KiB