Submission #25095

# Submission time Handle Problem Language Result Execution time Memory
25095 2017-06-20T06:45:52 Z 김동현(#1052) Sterilizing Spray (JOI15_sterilizing) C++14
10 / 100
3249 ms 2440 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 100000, B = 50;
int n, q, K;

struct Buc{
	int a[B], c, nc;
	ll s;
	void ch(int x, int v){ a[x] = v; }
	void dv(int x){ a[x] /= K; }
	void rs(){
		s = 0;
		for(int i = 0; i < B; i++) s += a[i];
	}
	void rn(){
		rs();
		c = nc = 0;
	}
	ll rec(){
		while(c <= 30 && c < nc){
			for(int i = 0; i < B; i++) a[i] /= K;
			c++;
		}
		rs();
		return s;
	}
};

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].rec();
			a[x / B].ch(x % B, y);
			a[x / B].rn();
		}
		else if(t == 2){
			x--; y--;
			int fl = 0;
			for(; x <= y && x % B; x++){ fl = 1; a[x / B].dv(x % B); }
			if(fl) a[x / B - 1].rn();
			for(; x + B <= y; x += B) a[x / B].nc++;
			fl = 0;
			for(; x <= y; x++){ fl = 1; a[y / B].dv(x % B); }
			if(fl) a[y / B].rn();
		}
		else{
			x--; y--;
			ll ans = 0;
			for(; x <= y && x % B; x++) ans += a[x / B].a[x % B];
			for(; x + B <= y; x += B) ans += a[x / B].rec();
			for(; x <= y; x++) ans += a[y / B].a[x % B];
			printf("%lld\n", ans);
		}
		//for(int i = 0; i < n; i++) printf("%d ", a[i / B].a[i % B]);
		//puts("");
	}
	//puts("");
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:34:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &q, &K);
                             ^
sterilizing.cpp:36:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a[i / B].a + (i % B));
                                    ^
sterilizing.cpp:40:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &t, &x, &y);
                              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 893 ms 2440 KB Output is correct
2 Correct 723 ms 2440 KB Output is correct
3 Correct 769 ms 2440 KB Output is correct
4 Correct 1089 ms 2440 KB Output is correct
5 Correct 1403 ms 2440 KB Output is correct
6 Correct 1403 ms 2440 KB Output is correct
7 Correct 1439 ms 2440 KB Output is correct
8 Correct 1353 ms 2440 KB Output is correct
9 Correct 3096 ms 2440 KB Output is correct
10 Correct 3249 ms 2440 KB Output is correct
11 Correct 3116 ms 2440 KB Output is correct
12 Correct 3233 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 2440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 686 ms 2440 KB Output isn't correct
2 Halted 0 ms 0 KB -