Submission #481086

# Submission time Handle Problem Language Result Execution time Memory
481086 2021-10-19T12:45:17 Z dxz05 Weighting stones (IZhO11_stones) C++14
0 / 100
1 ms 332 KB
#pragma GCC optimize("Ofast,O2,O3,unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << "[" << H << "]";
    debug_out(T...);
}

#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SZ(s) ((int)s.size())
#define all(x) (x).begin(), (x).end()
#define lla(x) (x).rbegin(), (x).rend()

clock_t startTime;

double getCurrentTime() {
    return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}

#define MP make_pair

typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.000001;
const int MOD = 998244353;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e5 + 3e2;
const int M = 5222;

struct SegTree{
    struct node{
        int val = 0;
        int add = 0;
    } t[4 * N];

    void push(int v){
        if (t[v].add == 0) return;
        t[v + v].val += t[v].add;
        t[v + v + 1].val += t[v].add;
        t[v + v].add = t[v + v + 1].add = t[v].add;
        t[v].add = 0;
    }

    void update(int l, int r, int val, int v, int tl, int tr){
        if (l <= tl && tr <= r){
            t[v].add += val;
            t[v].val += val;
            return;
        }
        if (tl > r || tr < l) return;
        push(v);
        int tm = (tl + tr) >> 1;
        update(l, r, val, v + v, tl, tm);
        update(l, r, val, v + v + 1, tm + 1, tr);
        t[v].val = min(t[v + v].val, t[v + v + 1].val);
    }

    void update(int l, int r, int val){
        update(l, r, val, 1, 1, N - 1);
    }

    int get() {
        return t[1].val;
    }

} a, b;

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

    for (int i = 1; i <= n; i++){
        int x, y;
        cin >> x >> y;
        x = n - x + 1;
        if (y == 1){
            a.update(x, N - 1, 1);
            b.update(x, N - 1, -1);
        } else {
            a.update(x, N - 1, -1);
            b.update(x, N - 1, 1);
        }

        x = a.get(), y = b.get();
        cout << (x > y ? '>' : x < y ? '<' : '?') << endl;

    }

}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int TC = 1;
//    cin >> TC;

    for (int test = 1; test <= TC; test++) {
        //debug(test);
        //cout << "Case #" << test << ": ";
        solve(test);
    }

    cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -