답안 #554782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554782 2022-04-29T11:48:00 Z cheetose Sterilizing Spray (JOI15_sterilizing) C++17
10 / 100
82 ms 10700 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

ll a[100005],T[100005];
int n,m,k;
void upd(int i,ll k){
	while(i<=n){
		T[i]+=k;
		i+=(i&-i);
	}
}
ll sum(int i){
	ll c=0;
	while(i>0){
		c+=T[i];
		i-=(i&-i);
	}
	return c;
}
int o[100000],x[100000],y[100000];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	fup(i,1,n,1)scanf("%lld",a+i);
	fup(i,0,m-1,1)scanf("%d%d%d",o+i,x+i,y+i);
	set<int> S;
	fup(i,1,n,1){
		if(a[i])S.insert(i);
		upd(i,a[i]);
	}
	fup(i,0,m-1,1){
		if(o[i]==1){
			if(y[i]>0)S.insert(i);
			else if(a[x[i]] && !y[i])S.erase(i);
			ll t=y[i]-a[x[i]];
			upd(x[i],t);
			a[x[i]]=y[i];
		}else if(o[i]==2){
			if(k==1)continue;
			auto it=S.lower_bound(x[i]);
			while(it!=S.end() && *it<=y[i]){
				int j=*it;
				ll nx=a[j]/k;
				upd(j,nx-a[j]);
				a[j]=nx;
				if(!nx)it=S.erase(it);
				else it++;
			}
		}else{
			printf("%lld\n",sum(y[i])-sum(x[i]-1));
		}
	}
	return 0;
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:62:2: note: in expansion of macro 'fup'
   62 |  fup(i,1,n,1)scanf("%lld",a+i);
      |  ^~~
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:63:2: note: in expansion of macro 'fup'
   63 |  fup(i,0,m-1,1)scanf("%d%d%d",o+i,x+i,y+i);
      |  ^~~
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:65:2: note: in expansion of macro 'fup'
   65 |  fup(i,1,n,1){
      |  ^~~
sterilizing.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
sterilizing.cpp:69:2: note: in expansion of macro 'fup'
   69 |  fup(i,0,m-1,1){
      |  ^~~
sterilizing.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |  scanf("%d%d%d",&n,&m,&k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
sterilizing.cpp:62:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |  fup(i,1,n,1)scanf("%lld",a+i);
      |              ~~~~~^~~~~~~~~~~~
sterilizing.cpp:63:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |  fup(i,0,m-1,1)scanf("%d%d%d",o+i,x+i,y+i);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 7372 KB Output is correct
2 Correct 41 ms 6348 KB Output is correct
3 Correct 45 ms 7796 KB Output is correct
4 Correct 58 ms 9780 KB Output is correct
5 Correct 65 ms 10608 KB Output is correct
6 Correct 69 ms 10700 KB Output is correct
7 Correct 73 ms 10628 KB Output is correct
8 Correct 82 ms 10540 KB Output is correct
9 Correct 66 ms 10520 KB Output is correct
10 Correct 63 ms 10444 KB Output is correct
11 Correct 70 ms 10436 KB Output is correct
12 Correct 67 ms 10404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 6136 KB Output isn't correct
2 Halted 0 ms 0 KB -