Submission #1086159

#TimeUsernameProblemLanguageResultExecution timeMemory
1086159TrinhKhanhDungWeighting stones (IZhO11_stones)C++14
0 / 100
35 ms6096 KiB
#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 == mi || (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 timeMemoryGrader output
Fetching results...