# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038535 | pera | Weighting stones (IZhO11_stones) | C++17 | 1 ms | 5464 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n;
vector<int> col(N) , cnt(2);
set<int> S;
vector<string> u = {">" , "<" , "?"};
struct node{
int mn = 0 , mx = 0 , lz = 0;
};
vector<node> t(4 * N);
void push(int u){
t[u * 2].mn += t[u].lz;
t[u * 2 + 1].mn += t[u].lz;
t[u * 2].mx += t[u].lz;
t[u * 2 + 1].mx += t[u].lz;
t[u].lz = 0;
}
void update(int u , int l , int r , int L , int R , int x){
if(l > r || r < L || l > R){
return;
}
if(L <= l && r <= R){
t[u].mn += x;
t[u].mx += x;
t[u].lz += x;
return;
}
push(u);
int m = (l + r) / 2;
update(u * 2 , l , m , L , R , x);
update(u * 2 + 1 , m + 1 , r , L , R , x);
t[u].mn = min(t[u * 2].mn , t[u * 2 + 1].mn);
t[u].mx = max(t[u * 2].mx , t[u * 2 + 1].mx);
}
void UPD(int x){
update(1 , 1 , n , 1 , x , (col[x] == 0 ? 1 : -1));
}
int main(){
cin >> n;
for(int i = 1;i <= n;i ++){
int r;
cin >> r;
cin >> col[r];
--col[r];
UPD(r);
if(t[1].mn >= 0){
cout << u[0] << endl;
continue;
}
if(t[1].mx <= 0){
cout << u[1] << endl;
continue;
}
cout << u[2] << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |