Submission #481092

# Submission time Handle Problem Language Result Execution time Memory
481092 2021-10-19T12:49:48 Z dxz05 Weighting stones (IZhO11_stones) C++14
100 / 100
60 ms 4676 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].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();
        debug(x, y);

        if (x < 0 && y < 0){
            cout << "?\n";
        } else if (x >= 0){
            cout << ">\n";
        } else cout << "<\n";

    }

}

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;
}

Compilation message

stones.cpp: In function 'void solve(int)':
stones.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
stones.cpp:99:9: note: in expansion of macro 'debug'
   99 |         debug(x, y);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 7 ms 716 KB Output is correct
11 Correct 37 ms 2768 KB Output is correct
12 Correct 60 ms 4244 KB Output is correct
13 Correct 53 ms 4548 KB Output is correct
14 Correct 48 ms 4536 KB Output is correct
15 Correct 52 ms 4552 KB Output is correct
16 Correct 58 ms 4676 KB Output is correct
17 Correct 52 ms 4568 KB Output is correct
18 Correct 52 ms 4548 KB Output is correct
19 Correct 50 ms 4556 KB Output is correct
20 Correct 48 ms 4512 KB Output is correct
21 Correct 56 ms 4548 KB Output is correct
22 Correct 58 ms 4580 KB Output is correct
23 Correct 54 ms 4568 KB Output is correct
24 Correct 52 ms 4576 KB Output is correct
25 Correct 51 ms 4636 KB Output is correct