#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M, Q;
cin >> N >> M >> Q;
vector<deque<int>> shops(N); // Vector of deques to represent customers in each shop
vector<int> results; // Vector to store the results of "Service" events
for (int i = 0; i < Q; ++i) {
int T;
cin >> T;
if (T == 1) { // Join event
int L, R, C, K;
cin >> L >> R >> C >> K;
for (int j = L - 1; j < R; ++j) {
for (int k = 0; k < K; ++k) {
shops[j].push_back(C);
}
}
} else if (T == 2) { // Leave event
int L, R, K;
cin >> L >> R >> K;
for (int j = L - 1; j < R; ++j) {
for (int k = 0; k < K && !shops[j].empty(); ++k) {
shops[j].pop_front();
}
}
} else if (T == 3) { // Service event
int A, B;
cin >> A >> B;
if (B <= shops[A - 1].size()) {
results.push_back(shops[A - 1][B - 1]);
} else {
results.push_back(0);
}
}
}
// Print all results of "Service" events
for (int result : results) {
cout << result << '\n';
}
return 0;
}
Compilation message
foodcourt.cpp: In function 'int main()':
foodcourt.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if (B <= shops[A - 1].size()) {
| ~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1628 KB |
Output is correct |
2 |
Correct |
4 ms |
2140 KB |
Output is correct |
3 |
Correct |
4 ms |
3236 KB |
Output is correct |
4 |
Correct |
6 ms |
4540 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
4444 KB |
Output is correct |
8 |
Correct |
6 ms |
3676 KB |
Output is correct |
9 |
Correct |
6 ms |
2140 KB |
Output is correct |
10 |
Correct |
6 ms |
3628 KB |
Output is correct |
11 |
Correct |
6 ms |
2908 KB |
Output is correct |
12 |
Correct |
5 ms |
2040 KB |
Output is correct |
13 |
Correct |
6 ms |
2396 KB |
Output is correct |
14 |
Correct |
8 ms |
2856 KB |
Output is correct |
15 |
Correct |
6 ms |
2648 KB |
Output is correct |
16 |
Correct |
8 ms |
2648 KB |
Output is correct |
17 |
Correct |
3 ms |
1372 KB |
Output is correct |
18 |
Correct |
5 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1628 KB |
Output is correct |
2 |
Correct |
4 ms |
2140 KB |
Output is correct |
3 |
Correct |
4 ms |
3236 KB |
Output is correct |
4 |
Correct |
6 ms |
4540 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
4444 KB |
Output is correct |
8 |
Correct |
6 ms |
3676 KB |
Output is correct |
9 |
Correct |
6 ms |
2140 KB |
Output is correct |
10 |
Correct |
6 ms |
3628 KB |
Output is correct |
11 |
Correct |
6 ms |
2908 KB |
Output is correct |
12 |
Correct |
5 ms |
2040 KB |
Output is correct |
13 |
Correct |
6 ms |
2396 KB |
Output is correct |
14 |
Correct |
8 ms |
2856 KB |
Output is correct |
15 |
Correct |
6 ms |
2648 KB |
Output is correct |
16 |
Correct |
8 ms |
2648 KB |
Output is correct |
17 |
Correct |
3 ms |
1372 KB |
Output is correct |
18 |
Correct |
5 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Runtime error |
562 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
44516 KB |
Output is correct |
2 |
Correct |
512 ms |
44328 KB |
Output is correct |
3 |
Correct |
662 ms |
44224 KB |
Output is correct |
4 |
Correct |
661 ms |
44236 KB |
Output is correct |
5 |
Correct |
545 ms |
44584 KB |
Output is correct |
6 |
Correct |
538 ms |
44576 KB |
Output is correct |
7 |
Correct |
12 ms |
600 KB |
Output is correct |
8 |
Correct |
12 ms |
604 KB |
Output is correct |
9 |
Execution timed out |
1064 ms |
44320 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
455 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1628 KB |
Output is correct |
2 |
Correct |
4 ms |
2140 KB |
Output is correct |
3 |
Correct |
4 ms |
3236 KB |
Output is correct |
4 |
Correct |
6 ms |
4540 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
4444 KB |
Output is correct |
8 |
Correct |
6 ms |
3676 KB |
Output is correct |
9 |
Correct |
6 ms |
2140 KB |
Output is correct |
10 |
Correct |
6 ms |
3628 KB |
Output is correct |
11 |
Correct |
6 ms |
2908 KB |
Output is correct |
12 |
Correct |
5 ms |
2040 KB |
Output is correct |
13 |
Correct |
6 ms |
2396 KB |
Output is correct |
14 |
Correct |
8 ms |
2856 KB |
Output is correct |
15 |
Correct |
6 ms |
2648 KB |
Output is correct |
16 |
Correct |
8 ms |
2648 KB |
Output is correct |
17 |
Correct |
3 ms |
1372 KB |
Output is correct |
18 |
Correct |
5 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Correct |
668 ms |
44516 KB |
Output is correct |
22 |
Correct |
512 ms |
44328 KB |
Output is correct |
23 |
Correct |
662 ms |
44224 KB |
Output is correct |
24 |
Correct |
661 ms |
44236 KB |
Output is correct |
25 |
Correct |
545 ms |
44584 KB |
Output is correct |
26 |
Correct |
538 ms |
44576 KB |
Output is correct |
27 |
Correct |
12 ms |
600 KB |
Output is correct |
28 |
Correct |
12 ms |
604 KB |
Output is correct |
29 |
Execution timed out |
1064 ms |
44320 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
528 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1628 KB |
Output is correct |
2 |
Correct |
4 ms |
2140 KB |
Output is correct |
3 |
Correct |
4 ms |
3236 KB |
Output is correct |
4 |
Correct |
6 ms |
4540 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
4444 KB |
Output is correct |
8 |
Correct |
6 ms |
3676 KB |
Output is correct |
9 |
Correct |
6 ms |
2140 KB |
Output is correct |
10 |
Correct |
6 ms |
3628 KB |
Output is correct |
11 |
Correct |
6 ms |
2908 KB |
Output is correct |
12 |
Correct |
5 ms |
2040 KB |
Output is correct |
13 |
Correct |
6 ms |
2396 KB |
Output is correct |
14 |
Correct |
8 ms |
2856 KB |
Output is correct |
15 |
Correct |
6 ms |
2648 KB |
Output is correct |
16 |
Correct |
8 ms |
2648 KB |
Output is correct |
17 |
Correct |
3 ms |
1372 KB |
Output is correct |
18 |
Correct |
5 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Runtime error |
562 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1628 KB |
Output is correct |
2 |
Correct |
4 ms |
2140 KB |
Output is correct |
3 |
Correct |
4 ms |
3236 KB |
Output is correct |
4 |
Correct |
6 ms |
4540 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
4444 KB |
Output is correct |
8 |
Correct |
6 ms |
3676 KB |
Output is correct |
9 |
Correct |
6 ms |
2140 KB |
Output is correct |
10 |
Correct |
6 ms |
3628 KB |
Output is correct |
11 |
Correct |
6 ms |
2908 KB |
Output is correct |
12 |
Correct |
5 ms |
2040 KB |
Output is correct |
13 |
Correct |
6 ms |
2396 KB |
Output is correct |
14 |
Correct |
8 ms |
2856 KB |
Output is correct |
15 |
Correct |
6 ms |
2648 KB |
Output is correct |
16 |
Correct |
8 ms |
2648 KB |
Output is correct |
17 |
Correct |
3 ms |
1372 KB |
Output is correct |
18 |
Correct |
5 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
1372 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Runtime error |
562 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |