Submission #69439

# Submission time Handle Problem Language Result Execution time Memory
69439 2018-08-20T21:06:39 Z thebes Sterilizing Spray (JOI15_sterilizing) C++14
0 / 100
2 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

const int MN = 1e5+5;
typedef long long ll;
ll bit[MN], arr[MN], N, M, K, i, x, y;
set<ll> s;

void upd(ll p,ll d){for(;p<=N;p+=p&-p)bit[p]+=d;}
ll qu(ll p){ll s=0;for(;p;p-=p&-p)s+=bit[p]; return s;}

int main(){
	freopen("03-01.txt","r",stdin);
	freopen("out.txt","w",stdout);
	scanf("%lld%lld%lld",&N,&M,&K);
	for(i=1;i<=N;i++){
		scanf("%lld",&arr[i]);
		upd(i, arr[i]);
		if(arr[i]) s.insert(i);
	}
	for(;M;M--){
		scanf("%lld%lld%lld",&i,&x,&y);
		if(i==1){
			upd(x, y-arr[x]); arr[x] = y;
			s.insert(x);
		}
		else if(i==2&&K!=1){
			auto it = s.lower_bound(x);
			for(;it!=s.end()&&*it<=y;){
				upd(*it,(arr[*it]/K)-arr[*it]);
				arr[*it]=arr[*it]/K;
				if(!arr[*it]){
					auto it2 = it; it++;
					s.erase(it2);
				}
				else it++;
			}
		}
		else printf("%lld\n",qu(y)-qu(x-1));
	}
	return 0;
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("03-01.txt","r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("out.txt","w",stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&N,&M,&K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&arr[i]);
   ~~~~~^~~~~~~~~~~~~~~~
sterilizing.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld",&i,&x,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -