답안 #554734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554734 2022-04-29T10:23:36 Z cheetose Sterilizing Spray (JOI15_sterilizing) C++17
0 / 100
37 ms 4900 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],tree[100005];
int n,m,k;
void upd(int i,ll k){
	while(i<=n){
		tree[i]+=k;
		i+=(i&-i);
	}
}
ll sum(int i){
	ll c=0;
	while(i>0){
		c+=tree[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);
	if(k==1){
		fup(i,1,n,1)upd(i,a[i]);
		fup(i,0,m-1,1){
			if(o[i]==2)continue;
			if(o[i]==1){
				ll t=y[i]-a[i];
				upd(i,t);
				a[i]=y[i];
			}else{
				printf("%lld\n",sum(y[i])-sum(x[i]-1));
			}
		}
	}
}

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:3: note: in expansion of macro 'fup'
   65 |   fup(i,1,n,1)upd(i,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:66:3: note: in expansion of macro 'fup'
   66 |   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 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 4900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2952 KB Output isn't correct
2 Halted 0 ms 0 KB -