#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}
//freopen("problemname.in", "r", stdin);
//freopen("problemname.out", "w", stdout);
struct item {
ll a , b;
};
struct Seg {
vector<item> v;
vector<ll> arr;
int siz;
item nutral = {0,0};
item merge(item x , item y){
ll a = min(x.b , y.a);
y.a -= a;
x.b -= a;
x.a += y.a;
x.b += y.b;
return x;
}
void init(int n){
siz = 1;
while(siz < n)siz *= 2;
v.assign(siz * 2 , nutral);
arr.assign(siz * 2 , 0);
}
ll find(int i , int x , int lx , int rx){
if(rx - lx == 1){
arr[x] -= v[x].a;
arr[x] = max(arr[x] , 0LL);
arr[x] += v[x].b;
return arr[x];
}
int m = (lx + rx)/2;
v[2 * x + 1] = merge(v[2 * x + 1] , v[x]);
v[2 * x + 2] = merge(v[2 * x + 2] , v[x]);
v[x] = nutral;
if(i < m){
return find(i , 2 * x + 1 , lx , m);
}
else return find(i , 2 * x + 2 , m , rx);
}
ll find(int i){
return find(i , 0 , 0 , siz);
}
void range(int l , int r , item it , int x , int lx , int rx){
if(l >= rx || r <= lx)return;
if(lx >= l && rx <= r){
v[x] = merge(v[x] , it);
return;
}
v[2 * x + 1] = merge(v[2 * x + 1] , v[x]);
v[2 * x + 2] = merge(v[2 * x + 2] , v[x]);
v[x] = nutral;
int m = (lx + rx)/2;
range(l , r , it , 2 * x + 1 , lx , m);
range(l , r , it , 2 * x + 2 , m , rx);
}
void range(int l , int r , item it){
range(l , r , it , 0 , 0 , siz);
}
};
void solve(){
int n , m , q;
cin >> n >> m >> q;
assert(m==1);
Seg st;
st.init(n);
item it;
while(q--){
int ti;
cin >> ti;
if(ti == 1){
int l , r, c , k;
cin >> l >> r >> c >> k;
it.a = 0;
it.b = k;
st.range(l-1 , r , it);
}
else if(ti == 2){
int l , r , k;
cin >> l >> r >> k;
it.a = k;
it.b = 0;
st.range(l -1 , r , it);
}
else {
ll a , b;
cin >> a >> b;
ll x = st.find(a-1);
if(x >= b)cout << 1 << '\n';
else cout << 0 << '\n';
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//int t;cin >> t;while(t--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
201 ms |
12772 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |