# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091165 | Phuoc | Weighting stones (IZhO11_stones) | C++14 | 43 ms | 6116 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;
#define ll long long
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define el '\n'
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define MASK(i) (1LL << (i))
#define fi first
#define se second
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>
bool maximize(T1 &a, T2 b) {
if(a < b) {a = b; return true;} return false;
}
const int MOD = 1337377;
template <class T1, class T2>
void add(T1 &a, T2 b) {
a += b;
if(a >= MOD) a -= MOD;
}
const ll INF = (ll)1e18 + 10LL;
const int oo = (int)1e9 + 10;
const int MAX = (int)1e5 + 10;
const int LG = 18;
int numStone;
void init (void) {
cin >> numStone;
}
struct seg {
vector <int> minVal, maxVal, lazy;
seg (int n = 0) {
minVal.resize(n * 4 + 10, 0);
maxVal.resize(n * 4 + 10, 0);
lazy.resize(n * 4 + 10, 0);
}
void pushDown(int i) {
for(int t = i * 2; t <= i * 2 + 1; t++) {
minVal[t] += lazy[i];
maxVal[t] += lazy[i];
lazy[t] += lazy[i];
}
lazy[i] = 0;
}
void update(int u, int v, int c, int i = 1, int l = 1, int r = numStone) {
if (u > r || v < l) return;
if(u <= l && r <= v) {
minVal[i] += c;
maxVal[i] += c;
lazy[i] += c;
return;
}
pushDown(i);
int m = (l + r) >> 1;
update(u, v, c, i * 2, l, m);
update(u, v, c, i * 2 + 1, m + 1, r);
minVal[i] = min(minVal[i * 2], minVal[i * 2 + 1]);
maxVal[i] = max(maxVal[i * 2], maxVal[i * 2 + 1]);
}
};
void solve (void) {
seg it (numStone);
for(int i = 1; i <= numStone; i++) {
int rank, side;
cin >> rank >> side;
if(side == 1) it.update(1, rank, 1);
else it.update(1, rank, -1);
int ma = it.maxVal[1], mi = it.minVal[1];
if(ma <= 0) cout << '<' << el;
else if(mi >= 0) cout << '>' << el;
else cout << '?' << el;
}
}
int main (void) {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "test"
int ntest = 1;
// cin >> ntest;
// srand(time(0));
while(ntest--) {
init();
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |