이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define Neco "Sterilizing Spray"
#define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define getbit(x,i) ((x >> i)&1)
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define cntbit(x) __builtin_popcountll(x)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define maxn (int) 1e5 + 7
using namespace std;
const ll mod = 1e9 + 7; //972663749
const ll base = 911382323;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r)
{
return uniform_int_distribution<ll> (l, r)(rng);
}
int n, q, k;
struct IT {
struct Node {
ll Amax, Sum;
} st[4 * maxn];
void update(int u, int v, int val, int id = 1, int l = 1, int r = n)
{
if(l > v || r < u) return;
if(st[id].Amax <= 0 && val < 0) return;
if(l == r) {
st[id].Sum = val < 0 ? st[id].Sum / k : val;
st[id].Amax = st[id].Sum;
return;
}
int mid = (l + r) >> 1;
update(u, v, val, _left), update(u, v, val, _right);
st[id].Amax = max(st[id * 2].Amax, st[id * 2 + 1].Amax);
st[id].Sum = st[id * 2].Sum + st[id * 2 + 1].Sum;
}
ll get(int u, int v, int id = 1, int l = 1, int r = n)
{
if(l > v || r < u) return 0;
if(u <= l && r <= v) return st[id].Sum;
int mid = (l + r) >> 1;
return get(u, v, _left) + get(u, v, _right);
}
} St;
void solve()
{
cin >> n >> q >> k;
int X;
fi(i, 1, n) cin >> X, St.update(i, i, X);
fi(i, 1, q) {
int type, x, y;
cin >> type >> x >> y;
if(type == 1) St.update(x, x, y);
if(type == 2) St.update(x, y, -1);
if(type == 3) cout << St.get(x, y) << '\n';
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen(Neco".inp", "r")) {
freopen(Neco".inp", "r", stdin);
freopen(Neco".out", "w", stdout);
}
int nTest = 1;
// cin >> nTest;
while(nTest--)
{
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sterilizing.cpp: In function 'int main()':
sterilizing.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
92 | freopen(Neco".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
93 | freopen(Neco".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |