Submission #1065299

# Submission time Handle Problem Language Result Execution time Memory
1065299 2024-08-19T06:06:47 Z 김은성(#11116) Food Court (JOI21_foodcourt) C++17
0 / 100
330 ms 16840 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 3.1557e18;
ll mn[1<<19], mn2[1<<19], lazy[1<<19], setup[1<<19];
void mergenode(int v){
	if(mn[2*v] < mn[2*v+1]){
		mn[v] = mn[2*v];
		mn2[v] = min(mn2[2*v], mn[2*v+1]);
	}
	else if(mn[2*v] > mn[2*v+1]){
		mn[v] = mn[2*v+1];
		mn2[v] = min(mn2[2*v+1], mn[2*v]);
	}
	else{
		mn[v] = mn[2*v];
		mn2[v] = min(mn2[2*v], mn2[2*v+1]);
	}
}
void propagate_lazy(int v, ll val){
	if(setup[2*v] != -1)
		setup[2*v] += val;
	else
		lazy[2*v] += val;
	if(setup[2*v+1] != -1)
		setup[2*v+1] += val;
	else
		lazy[2*v+1] += val;
}
void dolazy(int v, bool op){
	if(setup[v] != -1){
		mn[v] = setup[v];
		mn2[v] = INF;
		if(!op)
			setup[2*v] = setup[2*v+1] = setup[v];
	}
	else{
		mn[v] = max(mn[v] + lazy[v], 0ll);
		mn2[v] += lazy[v];
		assert(mn2[v] > 0);
		if(!op)
			propagate_lazy(v, lazy[v]);
	}
	setup[v] = -1;
	lazy[v] = 0;
}
void update(int v, int l, int r, int s, int e, ll d){
	dolazy(v, l==r);
	if(e<l || r<s)
		return;
	if(s<=l && r<=e){
		if(mn[v] > -d){
			mn[v] += d;
			mn2[v] += d;
			if(l != r)
				propagate_lazy(v, d);
			return;
		}
		else if(mn2[v] > -d){
			mn[v] = 0;
			mn2[v] += d;
			if(l != r)
				propagate_lazy(v, d);
			return;
		}
	}
	int mid = (l+r)/2;
	update(2*v, l, mid, s, e, d);
	update(2*v+1, mid+1, r, s, e, d);
	mergenode(v);
}
ll pointvalue(int v, int l, int r, int idx){
	dolazy(v, l==r);
	if(l==r)
		return mn[v];
	int mid = (l+r)/2;
	if(idx <= mid)
		return pointvalue(2*v, l, mid, idx);
	return pointvalue(2*v+1, mid+1, r, idx);
}
int main(){
	int n, m, q, i, type, l, r, c, a;
	ll k, b;
	scanf("%d %d %d", &n, &m, &q);
	assert(m==1);
	memset(setup, -1, sizeof(setup));
	memset(mn2, 127, sizeof(mn2));
	for(i=1; i<=q; i++){
		scanf("%d", &type);
		if(type==1){
			scanf("%d %d %d %lld", &l, &r, &c, &k);
			update(1, 1, n, l, r, k);
		}
		else if(type==2){
			scanf("%d %d %lld", &l, &r, &k);
			update(1, 1, n, l, r, -k);
		}
		else{
			scanf("%d %lld", &a, &b);
			if(pointvalue(1, 1, n, a) >= b)
				printf("1\n");
			else
				printf("0\n");
		}
	}
	return 0;
}

Compilation message

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:84:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |  scanf("%d %d %d", &n, &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:89:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |   scanf("%d", &type);
      |   ~~~~~^~~~~~~~~~~~~
foodcourt.cpp:91:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |    scanf("%d %d %d %lld", &l, &r, &c, &k);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:95:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |    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);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 330 ms 16840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -