답안 #554737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554737 2022-04-29T10:27:15 Z cheetose Sterilizing Spray (JOI15_sterilizing) C++17
10 / 100
64 ms 5908 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[x[i]];
				upd(x[i],t);
				a[x[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 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 2624 KB Output is correct
2 Correct 47 ms 3904 KB Output is correct
3 Correct 28 ms 4088 KB Output is correct
4 Correct 37 ms 5196 KB Output is correct
5 Correct 44 ms 5908 KB Output is correct
6 Correct 46 ms 5884 KB Output is correct
7 Correct 48 ms 5844 KB Output is correct
8 Correct 45 ms 5868 KB Output is correct
9 Correct 41 ms 5808 KB Output is correct
10 Correct 42 ms 5712 KB Output is correct
11 Correct 59 ms 5804 KB Output is correct
12 Correct 64 ms 5792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -