Submission #1086166

# Submission time Handle Problem Language Result Execution time Memory
1086166 2024-09-09T16:25:27 Z TrinhKhanhDung Weighting stones (IZhO11_stones) C++14
100 / 100
42 ms 5496 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 > 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;
}
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 860 KB Output is correct
11 Correct 32 ms 3160 KB Output is correct
12 Correct 38 ms 4700 KB Output is correct
13 Correct 32 ms 5212 KB Output is correct
14 Correct 36 ms 5316 KB Output is correct
15 Correct 34 ms 5208 KB Output is correct
16 Correct 35 ms 5184 KB Output is correct
17 Correct 35 ms 5340 KB Output is correct
18 Correct 34 ms 5212 KB Output is correct
19 Correct 31 ms 5184 KB Output is correct
20 Correct 31 ms 5212 KB Output is correct
21 Correct 42 ms 5496 KB Output is correct
22 Correct 41 ms 5252 KB Output is correct
23 Correct 32 ms 5212 KB Output is correct
24 Correct 32 ms 5236 KB Output is correct
25 Correct 36 ms 5212 KB Output is correct