# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25120 | 2017-06-20T07:13:11 Z | 김동현(#1052) | Sterilizing Spray (JOI15_sterilizing) | C++14 | 5000 ms | 2456 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 100000, B = 41; int n, q, K; struct Buc{ int a[B], c, nc; ll s; void ch(int x, int v){ s -= a[x]; a[x] = v; s += a[x]; } void dv(int x){ s -= a[x]; a[x] /= K; s += a[x]; } ll rec(){ while(c <= 30 && c < nc){ int fl = 0; for(int i = 0; i < B; i++){ if(a[i]){ dv(i); fl = 1; } } if(!fl) break; c++; } return s; } void rn(){ rec(); c = nc = 0; } }; Buc a[MX / B + 1]; int main(){ scanf("%d%d%d", &n, &q, &K); for(int i = 0; i < n; i++){ scanf("%d", a[i / B].a + (i % B)); a[i / B].s += a[i / B].a[i % B]; } for(int t, x, y; q--; ){ scanf("%d%d%d", &t, &x, &y); if(t == 1){ x--; a[x / B].rn(); a[x / B].ch(x % B, y); } else if(t == 2){ x--; y--; if(x % B) a[x / B].rn(); for(; x <= y && x % B; x++) a[x / B].dv(x % B); for(; x + B <= y; x += B) a[x / B].nc++; if(x <= y) a[x / B].rn(); for(; x <= y; x++) a[x / B].dv(x % B); } else{ x--; y--; ll ans = 0; if(x % B) a[x / B].rec(); for(; x <= y && x % B; x++) ans += a[x / B].a[x % B]; for(; x + B <= y; x += B) ans += a[x / B].rec(); if(x <= y) a[x / B].rec(); for(; x <= y; x++) ans += a[x / B].a[x % B]; printf("%lld\n", ans); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2456 KB | Output is correct |
2 | Correct | 0 ms | 2456 KB | Output is correct |
3 | Correct | 0 ms | 2456 KB | Output is correct |
4 | Correct | 0 ms | 2456 KB | Output is correct |
5 | Correct | 3 ms | 2456 KB | Output is correct |
6 | Correct | 3 ms | 2456 KB | Output is correct |
7 | Correct | 0 ms | 2456 KB | Output is correct |
8 | Correct | 3 ms | 2456 KB | Output is correct |
9 | Correct | 3 ms | 2456 KB | Output is correct |
10 | Correct | 0 ms | 2456 KB | Output is correct |
11 | Correct | 6 ms | 2456 KB | Output is correct |
12 | Correct | 6 ms | 2456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 676 ms | 2456 KB | Output is correct |
2 | Correct | 599 ms | 2456 KB | Output is correct |
3 | Correct | 479 ms | 2456 KB | Output is correct |
4 | Correct | 679 ms | 2456 KB | Output is correct |
5 | Correct | 856 ms | 2456 KB | Output is correct |
6 | Correct | 863 ms | 2456 KB | Output is correct |
7 | Correct | 896 ms | 2456 KB | Output is correct |
8 | Correct | 899 ms | 2456 KB | Output is correct |
9 | Correct | 1166 ms | 2456 KB | Output is correct |
10 | Correct | 1069 ms | 2456 KB | Output is correct |
11 | Correct | 1103 ms | 2456 KB | Output is correct |
12 | Correct | 1123 ms | 2456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 2456 KB | Output is correct |
2 | Correct | 86 ms | 2456 KB | Output is correct |
3 | Correct | 166 ms | 2456 KB | Output is correct |
4 | Correct | 339 ms | 2456 KB | Output is correct |
5 | Correct | 1389 ms | 2456 KB | Output is correct |
6 | Correct | 1289 ms | 2456 KB | Output is correct |
7 | Correct | 963 ms | 2456 KB | Output is correct |
8 | Correct | 1303 ms | 2456 KB | Output is correct |
9 | Correct | 4943 ms | 2456 KB | Output is correct |
10 | Correct | 4666 ms | 2456 KB | Output is correct |
11 | Correct | 4676 ms | 2456 KB | Output is correct |
12 | Correct | 4633 ms | 2456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 509 ms | 2456 KB | Output is correct |
2 | Correct | 576 ms | 2456 KB | Output is correct |
3 | Correct | 333 ms | 2456 KB | Output is correct |
4 | Correct | 483 ms | 2456 KB | Output is correct |
5 | Correct | 1333 ms | 2456 KB | Output is correct |
6 | Correct | 1333 ms | 2456 KB | Output is correct |
7 | Correct | 1323 ms | 2456 KB | Output is correct |
8 | Correct | 1389 ms | 2456 KB | Output is correct |
9 | Execution timed out | 5000 ms | 2456 KB | Execution timed out |
10 | Halted | 0 ms | 0 KB | - |