답안 #1086159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086159 2024-09-09T16:18:34 Z TrinhKhanhDung 돌 무게 재기 (IZhO11_stones) C++14
0 / 100
35 ms 6096 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(998244353)

using namespace std;

template<class T1, class T2>
    bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

template<class T1, class T2>
    bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}

template<class T1, class T2>
    void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}

template<class T1, class T2>
    void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}

template<class T>
    void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}

struct seg{
    vector<int> ma, mi, laz;
    int n;

    seg(int _n = 0){
        n = _n;
        ma.resize(n * 4 + 3, 0);
        mi.resize(n * 4 + 3, 0);
        laz.resize(n * 4 + 3, 0);
    }

    void push(int i){
        ma[i * 2] += laz[i];
        ma[i * 2 + 1] += laz[i];
        mi[i * 2] += laz[i];
        mi[i * 2 + 1] += laz[i];
        laz[i * 2] += laz[i];
        laz[i * 2 + 1] += laz[i];
        laz[i] = 0;
    }

    void upd(int i, int l, int r, int u, int v, int c){
        if(r < u || v < l) return;
        if(u <= l && r <= v){
            ma[i] += c;
            mi[i] += c;
            laz[i] += c;
            return;
        }
        push(i);
        int m = (l + r) >> 1;
        upd(i * 2, l, m, u, v, c);
        upd(i * 2 + 1, m + 1, r, u, v, c);
        mi[i] = min(mi[i * 2], mi[i * 2 + 1]);
        ma[i] = max(ma[i * 2], ma[i * 2 + 1]);
    }

    void upd(int u, int v, int c){
        upd(1, 1, n, u, v, c);
    }
};

void solve(){
    int n;
    cin >> n;

    seg it(n);
    while(n--){
        int a, b;
        cin >> a >> b;
        if(b == 1){
            it.upd(1, a, -1);
        }
        else{
            it.upd(1, a, 1);
        }

        int ma = it.ma[1], mi = it.mi[1];

        if(ma == mi || (ma > 0 && mi < 0))
            cout << "?\n";
        else if(ma <= 0)
            cout << ">\n";
        else
            cout << "<\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen("numtable.inp","r",stdin);
//    freopen("numtable.out","w",stdout);

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 408 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 20 ms 3620 KB Output is correct
12 Correct 35 ms 5468 KB Output is correct
13 Correct 32 ms 5976 KB Output is correct
14 Correct 33 ms 6096 KB Output is correct
15 Correct 34 ms 6076 KB Output is correct
16 Correct 32 ms 5968 KB Output is correct
17 Incorrect 31 ms 5980 KB Output isn't correct
18 Halted 0 ms 0 KB -