# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086166 | TrinhKhanhDung | Weighting stones (IZhO11_stones) | C++14 | 42 ms | 5496 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>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(998244353)
using namespace std;
template<class T1, class T2>
bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2>
bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2>
void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}
template<class T1, class T2>
void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}
template<class T>
void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
struct seg{
vector<int> ma, mi, laz;
int n;
seg(int _n = 0){
n = _n;
ma.resize(n * 4 + 3, 0);
mi.resize(n * 4 + 3, 0);
laz.resize(n * 4 + 3, 0);
}
void push(int i){
ma[i * 2] += laz[i];
ma[i * 2 + 1] += laz[i];
mi[i * 2] += laz[i];
mi[i * 2 + 1] += laz[i];
laz[i * 2] += laz[i];
laz[i * 2 + 1] += laz[i];
laz[i] = 0;
}
void upd(int i, int l, int r, int u, int v, int c){
if(r < u || v < l) return;
if(u <= l && r <= v){
ma[i] += c;
mi[i] += c;
laz[i] += c;
return;
}
push(i);
int m = (l + r) >> 1;
upd(i * 2, l, m, u, v, c);
upd(i * 2 + 1, m + 1, r, u, v, c);
mi[i] = min(mi[i * 2], mi[i * 2 + 1]);
ma[i] = max(ma[i * 2], ma[i * 2 + 1]);
}
void upd(int u, int v, int c){
upd(1, 1, n, u, v, c);
}
};
void solve(){
int n;
cin >> n;
seg it(n);
while(n--){
int a, b;
cin >> a >> b;
if(b == 1){
it.upd(1, a, -1);
}
else{
it.upd(1, a, 1);
}
int ma = it.ma[1], mi = it.mi[1];
if(ma > 0 && mi < 0)
cout << "?\n";
else if(ma <= 0)
cout << ">\n";
else
cout << "<\n";
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("numtable.inp","r",stdin);
// freopen("numtable.out","w",stdout);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |