QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#818303 | #9877. Segment Tree | ucup-team4975 | WA | 1ms | 3644kb | C++14 | 2.4kb | 2024-12-17 18:26:24 | 2024-12-17 18:26:24 |
Judging History
answer
#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif
#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif
#ifdef LOCAL
#define debugv(x) \
cerr << setw(4) << #x << ":: "; \
for (auto i : x) \
cerr << i << " "; \
cerr << endl
#else
#define debugv(x)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
out << x.fir << " " << x.sec << endl;
return out;
}
const int mod = 998244353;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = (1 << 18) + 10;
struct tree {
int l, r;
int val, mnval;
}t[N << 2];
void build (int p, int l, int r) {
t[p].mnval = t[p].val;
if (l + 1 == r) {
return;
}
int mid =(l + r) >> 1;
build (p << 1, l, mid);
build (p << 1 | 1, mid , r);
t[p].mnval = max(t[p << 1].val + t[p << 1 | 1].val, t[p].mnval);
}
void modify(int x, int y) {
t[x].val= y;
t[x].mnval = min(t[x].mnval, y);
while (x != 1) {
x = x >> 1;
t[x].mnval = min(t[x].val, t[x << 1].mnval + t[x << 1 | 1].mnval);
}
}
int getsum (int p, int l, int r) {
if (l <= t[p].l && t[p].r <= r) {
return t[p].mnval;
}
int mid = (t[p].l + t[p].r) >> 1;
ll sum = 0;
if (l < mid)
sum += getsum(p << 1, l, r);
if (r > mid)
sum += getsum(p << 1 | 1, l, r);
return sum;
}
int lowbit (int x) {
return x & (-x);
}
int query (int n, int s, int t) {
}
void solve()
{
int n;
cin >> n;
vector<int> val((1 << (n + 1)), 0);
for (int i = 1; i <= (1 << (n + 1)) - 1; i++) {
cin >> val[i];
t[i].val = val[i];
}
build(1, 0, (1 << n));
int q;
cin >> q;
while (q--) {
int inp, x, y, s, t;
cin >> inp;
if (inp == 1) {
cin >> x >> y;
modify(x, y);
}
else {
cin >> s >> t;
cout << query(n, s, t) << el;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3644kb
input:
3 7 1 14 3 9 4 8 2 6 5 5 13 8 2 3 10 2 0 1 2 0 4 2 4 6 2 4 8 2 3 5 1 6 30 2 3 5 2 4 6 1 1 10000000 2 0 8
output:
result:
wrong answer Unexpected EOF in the participants output