#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#define int long long
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define pi pair < int, int >
const int N = 65007;
const int INF = 1e9 + 7;
ll cnt[N];
int clr[N];
int n, m, q;
vector < pi > nxt[N];
vector < pi > gt[N];
int ans[N];
int t[4 * N];
void upd (int v, int l, int r, int pos, int val){
if (l == r)
t[v] += val;
else {
int mid = (l + r) >> 1;
if (pos <= mid)
upd(v + v, l, mid, pos, val);
else
upd(v + v + 1, mid + 1, r, pos, val);
t[v] = t[v + v] + t[v + v + 1];
}
}
int get (int v, int l, int r, int pos, int val){
if (l > pos)
return 0;
int mid = (l + r) >> 1;
if (r <= val){
if (t[v] < val)
return 0;
if (t[v + v] >= val)
return get(v + v, l, mid, pos, val);
val -= t[v + v];
return get(v + v + 1, mid + 1, r, pos, val);
}
else {
int r1 = get(v + v, l, mid, pos, val);
int r2 = get(v + v + 1, mid + 1, r, pos, val);
if (r2)
return r2;
return r1;
}
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> q;
for (int i = 1; i <= q; i++){
int t;
cin >> t;
if (t == 1){
int l, r, c, k;
cin >> l >> r >> c >> k;
clr[i] = c;
nxt[l].pb({i, k});
nxt[r + 1].pb({i, -k});
}
else if (t == 3){
int a;
ll b;
cin >> a >> b;
gt[a].pb({i, b});
}
else
return 0;
}
for (int i = 1; i <= n; i++){
for (auto it : nxt[i]){
upd(1, 1, q, it.fr, it.sc);
}
for (auto it : gt[i]){
ans[it.fr] = get(1, 1, q, it.fr, it.sc);
}
}
for (int i = 1; i <= q; i++){
if (ans[i] == -1)
cout << 0 << endl;
else if (ans[i])
cout << ans[i] << endl;
}
}
Compilation message
foodcourt.cpp:61:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
61 | main (){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
3276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
6628 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1062 ms |
446184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |