Submission #914952

#TimeUsernameProblemLanguageResultExecution timeMemory
914952adaawfWeighting stones (IZhO11_stones)C++14
100 / 100
55 ms5724 KiB
#include <iostream> #include <vector> using namespace std; int a[100005], b[100005], t[400005], lazy[400005], res[100005]; void push(int v) { t[v * 2] += lazy[v]; t[v * 2 + 1] += lazy[v]; lazy[v * 2] += lazy[v]; lazy[v * 2 + 1] += lazy[v]; lazy[v] = 0; } void update(int v, int tl, int tr, int l, int r, int x) { if (l > r) return; if (tl == l && tr == r) { t[v] += x; lazy[v] += x; return; } push(v); int mid = (tl + tr) / 2; update(v * 2, tl, mid, l, min(r, mid), x); update(v * 2 + 1, mid + 1, tr, max(l, mid + 1), r, x); t[v] = min(t[v * 2], t[v * 2 + 1]); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } for (int i = 1; i <= n; i++) { if (b[i] == 1) { update(1, 1, n, 1, a[i], -1); } else { update(1, 1, n, 1, a[i] - 1, 1); } if (t[1] >= 0) res[i] = 1; } for (int i = 1; i <= n * 4; i++) t[i] = lazy[i] = 0; for (int i = 1; i <= n; i++) { if (b[i] == 2) { update(1, 1, n, 1, a[i], -1); } else { update(1, 1, n, 1, a[i] - 1, 1); } if (t[1] >= 0) res[i] = 2; } for (int i = 1; i <= n; i++) { if (res[i] == 2) cout << '>'; else if (res[i] == 1) cout << '<'; else cout << '?'; cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...