#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
int N, M, Q, seg[300005];
deque<int> dq[65005];
void modify(int mL, int mR, int K, int i = 1, int L = 1, int R = N)
{
if (R < mL || mR < L)
return;
if (L == R)
{
while (!dq[L].empty() && K--)
dq[L].pop_front();
seg[i] = !dq[L].empty();
}
else if (seg[i])
{
int mid = (L + R) / 2;
modify(mL, mR, K, i * 2, L, mid);
modify(mL, mR, K, i * 2 + 1, mid + 1, R);
seg[i] = seg[i * 2] | seg[i * 2 + 1];
}
}
void insert(int pos, int C, int i = 1, int L = 1, int R = N)
{
if (L == R)
{
dq[L].emplace_back(C);
seg[i] = !dq[L].empty();
}
else
{
int mid = (L + R) / 2;
if (pos <= mid)
insert(pos, C, i * 2, L, mid);
else
insert(pos, C, i * 2 + 1, mid + 1, R);
seg[i] = seg[i * 2] | seg[i * 2 + 1];
}
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> M >> Q;
for (int i = 1; i <= Q; i++)
{
ll T, L, R, C, K;
cin >> T >> L >> R;
if (T == 1)
{
cin >> C >> K;
for (int j = L; j <= R; j++)
insert(j, C);
}
else if (T == 2)
{
cin >> K;
modify(L, R, K);
}
else if (T == 3)
cout << (dq[L].size() >= R ? dq[L][R - 1] : 0) << '\n';
}
}
Compilation message
foodcourt.cpp: In function 'int main()':
foodcourt.cpp:69:35: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
69 | cout << (dq[L].size() >= R ? dq[L][R - 1] : 0) << '\n';
| ~~~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
44244 KB |
Output is correct |
2 |
Correct |
72 ms |
44372 KB |
Output is correct |
3 |
Correct |
90 ms |
45732 KB |
Output is correct |
4 |
Correct |
118 ms |
46768 KB |
Output is correct |
5 |
Correct |
28 ms |
43988 KB |
Output is correct |
6 |
Correct |
30 ms |
44084 KB |
Output is correct |
7 |
Correct |
108 ms |
46656 KB |
Output is correct |
8 |
Correct |
104 ms |
46188 KB |
Output is correct |
9 |
Correct |
110 ms |
44492 KB |
Output is correct |
10 |
Correct |
102 ms |
46084 KB |
Output is correct |
11 |
Correct |
107 ms |
45288 KB |
Output is correct |
12 |
Correct |
136 ms |
44472 KB |
Output is correct |
13 |
Correct |
117 ms |
45020 KB |
Output is correct |
14 |
Correct |
158 ms |
45244 KB |
Output is correct |
15 |
Correct |
119 ms |
45052 KB |
Output is correct |
16 |
Correct |
157 ms |
45072 KB |
Output is correct |
17 |
Correct |
66 ms |
44212 KB |
Output is correct |
18 |
Correct |
93 ms |
44276 KB |
Output is correct |
19 |
Correct |
37 ms |
44012 KB |
Output is correct |
20 |
Correct |
30 ms |
43984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
44244 KB |
Output is correct |
2 |
Correct |
72 ms |
44372 KB |
Output is correct |
3 |
Correct |
90 ms |
45732 KB |
Output is correct |
4 |
Correct |
118 ms |
46768 KB |
Output is correct |
5 |
Correct |
28 ms |
43988 KB |
Output is correct |
6 |
Correct |
30 ms |
44084 KB |
Output is correct |
7 |
Correct |
108 ms |
46656 KB |
Output is correct |
8 |
Correct |
104 ms |
46188 KB |
Output is correct |
9 |
Correct |
110 ms |
44492 KB |
Output is correct |
10 |
Correct |
102 ms |
46084 KB |
Output is correct |
11 |
Correct |
107 ms |
45288 KB |
Output is correct |
12 |
Correct |
136 ms |
44472 KB |
Output is correct |
13 |
Correct |
117 ms |
45020 KB |
Output is correct |
14 |
Correct |
158 ms |
45244 KB |
Output is correct |
15 |
Correct |
119 ms |
45052 KB |
Output is correct |
16 |
Correct |
157 ms |
45072 KB |
Output is correct |
17 |
Correct |
66 ms |
44212 KB |
Output is correct |
18 |
Correct |
93 ms |
44276 KB |
Output is correct |
19 |
Correct |
37 ms |
44012 KB |
Output is correct |
20 |
Correct |
30 ms |
43984 KB |
Output is correct |
21 |
Incorrect |
70 ms |
44164 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
45696 KB |
Output is correct |
2 |
Correct |
105 ms |
45852 KB |
Output is correct |
3 |
Correct |
101 ms |
45732 KB |
Output is correct |
4 |
Correct |
105 ms |
45852 KB |
Output is correct |
5 |
Correct |
128 ms |
45728 KB |
Output is correct |
6 |
Correct |
123 ms |
45856 KB |
Output is correct |
7 |
Correct |
46 ms |
44836 KB |
Output is correct |
8 |
Correct |
65 ms |
44972 KB |
Output is correct |
9 |
Correct |
116 ms |
45752 KB |
Output is correct |
10 |
Correct |
94 ms |
45848 KB |
Output is correct |
11 |
Correct |
84 ms |
45856 KB |
Output is correct |
12 |
Correct |
84 ms |
45860 KB |
Output is correct |
13 |
Correct |
93 ms |
45524 KB |
Output is correct |
14 |
Correct |
103 ms |
45748 KB |
Output is correct |
15 |
Correct |
122 ms |
45872 KB |
Output is correct |
16 |
Correct |
147 ms |
45900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
71 ms |
89388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
44244 KB |
Output is correct |
2 |
Correct |
72 ms |
44372 KB |
Output is correct |
3 |
Correct |
90 ms |
45732 KB |
Output is correct |
4 |
Correct |
118 ms |
46768 KB |
Output is correct |
5 |
Correct |
28 ms |
43988 KB |
Output is correct |
6 |
Correct |
30 ms |
44084 KB |
Output is correct |
7 |
Correct |
108 ms |
46656 KB |
Output is correct |
8 |
Correct |
104 ms |
46188 KB |
Output is correct |
9 |
Correct |
110 ms |
44492 KB |
Output is correct |
10 |
Correct |
102 ms |
46084 KB |
Output is correct |
11 |
Correct |
107 ms |
45288 KB |
Output is correct |
12 |
Correct |
136 ms |
44472 KB |
Output is correct |
13 |
Correct |
117 ms |
45020 KB |
Output is correct |
14 |
Correct |
158 ms |
45244 KB |
Output is correct |
15 |
Correct |
119 ms |
45052 KB |
Output is correct |
16 |
Correct |
157 ms |
45072 KB |
Output is correct |
17 |
Correct |
66 ms |
44212 KB |
Output is correct |
18 |
Correct |
93 ms |
44276 KB |
Output is correct |
19 |
Correct |
37 ms |
44012 KB |
Output is correct |
20 |
Correct |
30 ms |
43984 KB |
Output is correct |
21 |
Correct |
87 ms |
45696 KB |
Output is correct |
22 |
Correct |
105 ms |
45852 KB |
Output is correct |
23 |
Correct |
101 ms |
45732 KB |
Output is correct |
24 |
Correct |
105 ms |
45852 KB |
Output is correct |
25 |
Correct |
128 ms |
45728 KB |
Output is correct |
26 |
Correct |
123 ms |
45856 KB |
Output is correct |
27 |
Correct |
46 ms |
44836 KB |
Output is correct |
28 |
Correct |
65 ms |
44972 KB |
Output is correct |
29 |
Correct |
116 ms |
45752 KB |
Output is correct |
30 |
Correct |
94 ms |
45848 KB |
Output is correct |
31 |
Correct |
84 ms |
45856 KB |
Output is correct |
32 |
Correct |
84 ms |
45860 KB |
Output is correct |
33 |
Correct |
93 ms |
45524 KB |
Output is correct |
34 |
Correct |
103 ms |
45748 KB |
Output is correct |
35 |
Correct |
122 ms |
45872 KB |
Output is correct |
36 |
Correct |
147 ms |
45900 KB |
Output is correct |
37 |
Execution timed out |
1083 ms |
56404 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1094 ms |
63792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
44244 KB |
Output is correct |
2 |
Correct |
72 ms |
44372 KB |
Output is correct |
3 |
Correct |
90 ms |
45732 KB |
Output is correct |
4 |
Correct |
118 ms |
46768 KB |
Output is correct |
5 |
Correct |
28 ms |
43988 KB |
Output is correct |
6 |
Correct |
30 ms |
44084 KB |
Output is correct |
7 |
Correct |
108 ms |
46656 KB |
Output is correct |
8 |
Correct |
104 ms |
46188 KB |
Output is correct |
9 |
Correct |
110 ms |
44492 KB |
Output is correct |
10 |
Correct |
102 ms |
46084 KB |
Output is correct |
11 |
Correct |
107 ms |
45288 KB |
Output is correct |
12 |
Correct |
136 ms |
44472 KB |
Output is correct |
13 |
Correct |
117 ms |
45020 KB |
Output is correct |
14 |
Correct |
158 ms |
45244 KB |
Output is correct |
15 |
Correct |
119 ms |
45052 KB |
Output is correct |
16 |
Correct |
157 ms |
45072 KB |
Output is correct |
17 |
Correct |
66 ms |
44212 KB |
Output is correct |
18 |
Correct |
93 ms |
44276 KB |
Output is correct |
19 |
Correct |
37 ms |
44012 KB |
Output is correct |
20 |
Correct |
30 ms |
43984 KB |
Output is correct |
21 |
Incorrect |
70 ms |
44164 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
44244 KB |
Output is correct |
2 |
Correct |
72 ms |
44372 KB |
Output is correct |
3 |
Correct |
90 ms |
45732 KB |
Output is correct |
4 |
Correct |
118 ms |
46768 KB |
Output is correct |
5 |
Correct |
28 ms |
43988 KB |
Output is correct |
6 |
Correct |
30 ms |
44084 KB |
Output is correct |
7 |
Correct |
108 ms |
46656 KB |
Output is correct |
8 |
Correct |
104 ms |
46188 KB |
Output is correct |
9 |
Correct |
110 ms |
44492 KB |
Output is correct |
10 |
Correct |
102 ms |
46084 KB |
Output is correct |
11 |
Correct |
107 ms |
45288 KB |
Output is correct |
12 |
Correct |
136 ms |
44472 KB |
Output is correct |
13 |
Correct |
117 ms |
45020 KB |
Output is correct |
14 |
Correct |
158 ms |
45244 KB |
Output is correct |
15 |
Correct |
119 ms |
45052 KB |
Output is correct |
16 |
Correct |
157 ms |
45072 KB |
Output is correct |
17 |
Correct |
66 ms |
44212 KB |
Output is correct |
18 |
Correct |
93 ms |
44276 KB |
Output is correct |
19 |
Correct |
37 ms |
44012 KB |
Output is correct |
20 |
Correct |
30 ms |
43984 KB |
Output is correct |
21 |
Incorrect |
70 ms |
44164 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |