#include<bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5+10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, m, que;
deque < pair < long long/**type*/, long long/**number*/ > > q[MAXN];
long long total[MAXN];
long long t;
long long l, r, c, k, a, b;
void read()
{
cin >> n >> m >> que;
for (long long i = 1; i <= que; ++ i)
{
cin >> t;
if(t == 1)
{
cin >> l >> r >> c >> k;
for (long long j = l; j <= r; ++ j)
{
q[j].push_back(make_pair(c, k));
total[j] += k;
}
}
else if(t == 2)
{
cin >> l >> r >> k;
for (long long j = l; j <= r; ++ j)
{
if(total[j] <= k)q[j].clear();
else
{
total[j] -= k;
while(k)
{
if(k > q[j].front().second)
{
k -= q[j].front().second;
q[j].pop_front();
}
else
{
q[j].front().second -= k;
k = 0;
}
}
}
}
}
else
{
cin >> a >> b;
// cout << "start " << endl;
if(total[a] < b)cout << 0 << endl;
else
{
deque < pair <long long, long long > >cut;
long long sum = b, last_colour = 0;
while(sum > 0)
{
sum -= q[a].front().second;
last_colour = q[a].front().first;
cut.push_back(q[a].front());
q[a].pop_front();
}
while(!cut.empty())
{
q[a].push_front(cut.back());
cut.pop_back();
}
cout << last_colour << endl;
}
}
}
}
int main()
{
speed();
read();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
206160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
206160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
327 ms |
411436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
240 ms |
413524 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
206160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
431 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
206160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
206160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |