답안 #438864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438864 2021-06-28T19:39:34 Z cheetose 푸드 코트 (JOI21_foodcourt) C++17
0 / 100
525 ms 12996 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 987654321
#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 = 1000000007;
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 };

Pll lazy[524288];
ll tree[524288];
void g(Pll &p1,Pll p2){
	if(p1.Y<=p2.X){
		p1.X+=p2.X-p1.Y;
		p1.Y=p2.Y;
	}else{
		p1.Y+=p2.Y-p2.X;
	}
}
void propagation(int node,int S,int E){
	tree[node]=max(tree[node]-lazy[node].X,0ll)+lazy[node].Y;
	if(S!=E){
		int L=node<<1,R=L|1;
		g(lazy[L],lazy[node]);
		g(lazy[R],lazy[node]);
	}
	lazy[node]=mp(0,0);
}
void upd(int node,int S,int E,int i,int j,ll k){
	propagation(node,S,E);
	if (i>E || j<S)return;
	if(i<=S && E<=j){
		if(k>0)lazy[node].Y+=k;
		else lazy[node].X-=k;
		propagation(node,S,E);
		return;
	}
	upd(node<<1,S,(S+E)/2,i,j,k);
	upd(node<<1|1,(S+E)/2+1,E,i,j,k);
}
ll find(int node,int S,int E,int i,int j){
	propagation(node,S,E);
	if (i>E || j<S)return 0;
	if(i<=S && E<=j)return tree[node];
	return find(node<<1,S,(S+E)/2,i,j)+find(node<<1|1,(S+E)/2+1,E,i,j);
}
int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	while(q--){
		int t;
		scanf("%d",&t);
		if(t==1){
			int l,r,c;
			ll k;
			scanf("%d%d%d%lld",&l,&r,&c,&k);
			upd(1,1,n,l,r,k);
		}else if(t==2){
			int l,r;
			ll k;
			scanf("%d%d%lld",&l,&r,&k);
			upd(1,1,n,l,r,-k);
		}else{
			int a;
			ll b;
			scanf("%d%lld",&a,&b);
			if(find(1,1,n,a,a)<=b)puts("1");
			else puts("0");
		}
	}
}

Compilation message

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:82:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |  scanf("%d%d%d",&n,&m,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
foodcourt.cpp:85:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |   scanf("%d",&t);
      |   ~~~~~^~~~~~~~~
foodcourt.cpp:89:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |    scanf("%d%d%d%lld",&l,&r,&c,&k);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:94:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |    scanf("%d%d%lld",&l,&r,&k);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:99:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |    scanf("%d%lld",&a,&b);
      |    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 3392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 525 ms 12996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 115 ms 3392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -