# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89878 | popovicirobert | Weighting stones (IZhO11_stones) | C++14 | 85 ms | 16932 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44
using namespace std;
const int MAXN = (int) 1e5;
struct Aint {
int mn, mx;
int lazy;
}aint[4 * MAXN + 1];
inline void solve_lazy(int nod) {
if(2 * nod + 1 <= 4 * MAXN) {
aint[2 * nod].lazy += aint[nod].lazy;
aint[2 * nod + 1].lazy += aint[nod].lazy;
}
aint[nod].mn += aint[nod].lazy;
aint[nod].mx += aint[nod].lazy;
aint[nod].lazy = 0;
}
inline void refresh(int nod) {
if(2 * nod + 1 > 4 * MAXN) {
return ;
}
solve_lazy(2 * nod);
solve_lazy(2 * nod + 1);
aint[nod].mn = min(aint[2 * nod].mn, aint[2 * nod + 1].mn);
aint[nod].mx = max(aint[2 * nod].mx, aint[2 * nod + 1].mx);
}
void update(int nod, int left, int right, int l, int r, int val) {
solve_lazy(nod);
if(l <= left && right <= r) {
aint[nod].lazy += val;
solve_lazy(nod);
}
else {
int mid = (left + right) / 2;
if(l <= mid)
update(2 * nod, left, mid, l, r, val);
if(mid < r)
update(2 * nod + 1, mid + 1, right, l, r, val);
}
refresh(nod);
}
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, n;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for(i = 1; i <= n; i++) {
int r, s;
cin >> r >> s;
if(s == 1) {
update(1, 1, n, 1, r, 1);
}
else {
update(1, 1, n, 1, r, -1);
}
if(aint[1].mn >= 0) {
cout << '>';
}
else if(aint[1].mx <= 0) {
cout << '<';
}
else {
cout << '?';
}
cout << "\n";
}
//cin.close();
//cout.close();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |