Submission #903263

# Submission time Handle Problem Language Result Execution time Memory
903263 2024-01-11T06:38:17 Z dsyz Weighting stones (IZhO11_stones) C++17
100 / 100
59 ms 10800 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (100005)
struct node{
  int s,e,m,maxv,minv,lazyadd;
  node *l,*r;
  node(int _s,int _e){
    s = _s;
    e = _e;
    m = (s + e) / 2;
    maxv = 0;
    minv = 0;
    lazyadd = 0;
    if(s != e){
      l = new node(s,m);
      r = new node(m + 1,e);
    }
  }
  void value(){
    if(s == e){
      maxv += lazyadd;
      minv += lazyadd;
      lazyadd = 0;
      return;
    }
    maxv += lazyadd;
    minv += lazyadd;
    r->lazyadd += lazyadd;
    l->lazyadd += lazyadd;
    lazyadd = 0;
    return;
  }
  void add(int x,int y,int val){
    if(s == x && e == y) lazyadd += val;
    else{
      if(x > m) r -> add(x,y,val);
      else if(y <= m) l -> add(x,y,val);
      else l -> add(x,m,val), r -> add(m + 1,y,val);
      l->value(), r->value();
      maxv = max(l->maxv,r->maxv);
      minv = min(l->minv,r->minv);
    }
  }
  int rmaxq(){
      value();
      return maxv;
  }
  int rminq(){
      value();
      return minv;
  }
} *root;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N;
	cin>>N;
	root = new node(0,N - 1);
	for(ll i = 0;i < N;i++){
		ll c,s;
		cin>>c>>s;
		c--;
		if(s == 1){
			root -> add(0,c,1);
		}else if(s == 2){
			root -> add(0,c,-1);
		}
		ll minimum = root -> rminq();
		ll maximum = root -> rmaxq();
		if(maximum <= 0) cout<<'<'<<'\n';
		else if(minimum >= 0) cout<<'>'<<'\n';
		else cout<<'?'<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 4 ms 1372 KB Output is correct
11 Correct 41 ms 6132 KB Output is correct
12 Correct 46 ms 9556 KB Output is correct
13 Correct 44 ms 10780 KB Output is correct
14 Correct 43 ms 10568 KB Output is correct
15 Correct 42 ms 10784 KB Output is correct
16 Correct 42 ms 10736 KB Output is correct
17 Correct 44 ms 10760 KB Output is correct
18 Correct 48 ms 10680 KB Output is correct
19 Correct 54 ms 10672 KB Output is correct
20 Correct 53 ms 10772 KB Output is correct
21 Correct 44 ms 10792 KB Output is correct
22 Correct 44 ms 10588 KB Output is correct
23 Correct 44 ms 10800 KB Output is correct
24 Correct 59 ms 10788 KB Output is correct
25 Correct 54 ms 10580 KB Output is correct