Submission #1016234

# Submission time Handle Problem Language Result Execution time Memory
1016234 2024-07-07T14:39:24 Z Minbaev Weighting stones (IZhO11_stones) C++17
100 / 100
30 ms 5828 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x)   (int)(x).size()
#define len(x)  (int)(x).length()
#define cntbit(x)  builtin_popcnt(x)
#define f   first
#define s   second
#define pb  push_back
 
const int N = 1e5 + 100;
pair <int, int> seg[N * 4];
int laz[N * 4];
 
void push(int id) {
    int t = laz[id];
    laz[id * 2] += t;
    laz[id * 2 + 1] += t;
    seg[id * 2].f += t, seg[id * 2].s += t, seg[id * 2 + 1].f += t, seg[id * 2 + 1].s += t;    
    laz[id] = 0;
}
 
void upd(int id, int l, int r, int u, int v, int add) {
    if (l > v || r < u)
        return;
 
    if (l >= u && r <= v) {
        laz[id] += add;
        seg[id].f += add, seg[id].s += add;
        return;
    }
 
    push(id);
    int m = (l + r) / 2;
    upd(id * 2, l, m, u, v, add);
    upd(id * 2 + 1, m + 1, r, u, v, add);
    seg[id].f = max(seg[id * 2].f, seg[id * 2 + 1].f);
    seg[id].s = min(seg[id * 2].s, seg[id * 2 + 1].s);
}
 
char check() {
    if (seg[1].s >= 0) {
        return '>';
    }
 
    if (seg[1].f <= 0) {
        return '<';
    }
 
    return '?';
}
 
ll solve() {
    int n;
    cin >> n;
 
    for (int i = 0; i < n; i++) {
        int r, s;
        cin >> r >> s;
 
        r = n - r + 1;
        if (s == 1) {
            upd(1, 1, n, r, n, 1);
        } else {
            upd(1, 1, n, r, n, -1);
        }
 
        cout << check() << '\n';
    }
 
    return 0;
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    //cin >> t;
 
    while (t--) {
        solve();
        //cout << solve() << '\n';
    }
 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 3 ms 2712 KB Output is correct
11 Correct 19 ms 5212 KB Output is correct
12 Correct 26 ms 5468 KB Output is correct
13 Correct 26 ms 5572 KB Output is correct
14 Correct 27 ms 5456 KB Output is correct
15 Correct 26 ms 5696 KB Output is correct
16 Correct 29 ms 5460 KB Output is correct
17 Correct 24 ms 5468 KB Output is correct
18 Correct 29 ms 5456 KB Output is correct
19 Correct 28 ms 5568 KB Output is correct
20 Correct 27 ms 5720 KB Output is correct
21 Correct 30 ms 5464 KB Output is correct
22 Correct 30 ms 5700 KB Output is correct
23 Correct 29 ms 5460 KB Output is correct
24 Correct 30 ms 5828 KB Output is correct
25 Correct 29 ms 5468 KB Output is correct