# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
694941 | Do_you_copy | Sterilizing Spray (JOI15_sterilizing) | C++17 | 183 ms | 10224 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>
#define fi first
#define se second
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define int long long
using namespace std;
using ll = long long;
using pii = pair <int, int>;
mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e5 +1;
const int inf = 0x3f3f3f3f;
//const int Mod =
int n, q, k;
ll bit[maxN];
map <int, int> mp;
void update(int x, int v){
for (; x <= n; x += x & -x){
bit[x] += v;
}
}
int get(int x){
int res = 0;
for (; x; x -= x & -x){
res += bit[x];
}
return res;
}
void Init(){
cin >> n >> q >> k;
for (int i = 1; i <= n; ++i){
cin >> mp[i];
update(i, mp[i]);
}
mp[n + 1] = 0;
while (q--){
int s, t, u;
cin >> s >> t >> u;
if (s == 1){
update(t, u - mp[t]);
mp[t] = u;
}
if (s == 2 && k != 1){
for (auto it = mp.lower_bound(t); it->fi <= u;){
auto it1 = it++;
int x = it1->se;
it1->se /= k;
update(it1->fi, it1->se - x);
if (it1->se == 0){
mp.erase(it1);
}
}
}
if (s == 3){
cout << get(u) - get(t - 1) << "\n";
}
}
}
#define taskname "test"
signed main(){
faster
if (fopen(taskname ".inp", "r")){
freopen(taskname ".inp", "r", stdin);
freopen(taskname ".out", "w", stdout);
}
int tt = 1;
//cin >> tt;
while (tt--){
Init();
}
}
Compilation message (stderr)
# | 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... |