#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Foxyy cin.tie(0); cout.tie(0); cout.sync_with_stdio(0);
const int INF = 0x3f3f3f3f;
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
struct Solver {
int &N, &M, &Q;
vector<deque<int>> qu;
Solver(int &_N, int &_M, int &_Q):
N(_N), M(_M), Q(_Q) {
qu.resize(N);
}
void enqueue(int L, int R, int C, int K) {
for(int i = L; i < R; i++) {
for(int k = 0; k < K; k++) {
qu[i].push_back(C);
}
}
}
void dequeue(int L, int R, int K) {
for(int i = L; i < R; i++) {
for(int k = 0; k < K; k++) {
if (qu[i].empty()) break;
qu[i].pop_front();
}
}
}
int query(int A, ll B) {
if ((int)qu[A].size() >= B) {
return qu[A][B-1];
} else {
return 0;
}
}
void solve() {
while(Q--) {
int T;
cin >> T;
if (T == 1) {
int L, R, C, K;
cin >> L >> R >> C >> K;
enqueue(L-1, R, C, K);
} else if (T == 2) {
int L, R, K;
cin >> L >> R >> K;
dequeue(L-1, R, K);
} else if (T == 3) {
int A;
ll B;
cin >> A >> B;
cout << query(A-1, B) << '\n';
}
}
}
};
signed main() {
Foxyy
int N, M, Q;
cin >> N >> M >> Q;
Solver solver{N, M, Q};
solver.solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1480 KB |
Output is correct |
2 |
Correct |
6 ms |
1996 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
9 ms |
4428 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
4332 KB |
Output is correct |
8 |
Correct |
10 ms |
3784 KB |
Output is correct |
9 |
Correct |
9 ms |
2124 KB |
Output is correct |
10 |
Correct |
9 ms |
3532 KB |
Output is correct |
11 |
Correct |
9 ms |
2892 KB |
Output is correct |
12 |
Correct |
9 ms |
1996 KB |
Output is correct |
13 |
Correct |
10 ms |
2476 KB |
Output is correct |
14 |
Correct |
14 ms |
2636 KB |
Output is correct |
15 |
Correct |
10 ms |
2636 KB |
Output is correct |
16 |
Correct |
17 ms |
2724 KB |
Output is correct |
17 |
Correct |
5 ms |
1352 KB |
Output is correct |
18 |
Correct |
9 ms |
1864 KB |
Output is correct |
19 |
Correct |
2 ms |
1392 KB |
Output is correct |
20 |
Correct |
2 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1480 KB |
Output is correct |
2 |
Correct |
6 ms |
1996 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
9 ms |
4428 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
4332 KB |
Output is correct |
8 |
Correct |
10 ms |
3784 KB |
Output is correct |
9 |
Correct |
9 ms |
2124 KB |
Output is correct |
10 |
Correct |
9 ms |
3532 KB |
Output is correct |
11 |
Correct |
9 ms |
2892 KB |
Output is correct |
12 |
Correct |
9 ms |
1996 KB |
Output is correct |
13 |
Correct |
10 ms |
2476 KB |
Output is correct |
14 |
Correct |
14 ms |
2636 KB |
Output is correct |
15 |
Correct |
10 ms |
2636 KB |
Output is correct |
16 |
Correct |
17 ms |
2724 KB |
Output is correct |
17 |
Correct |
5 ms |
1352 KB |
Output is correct |
18 |
Correct |
9 ms |
1864 KB |
Output is correct |
19 |
Correct |
2 ms |
1392 KB |
Output is correct |
20 |
Correct |
2 ms |
1612 KB |
Output is correct |
21 |
Runtime error |
710 ms |
524292 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
931 ms |
45292 KB |
Output is correct |
2 |
Correct |
712 ms |
45332 KB |
Output is correct |
3 |
Correct |
865 ms |
45304 KB |
Output is correct |
4 |
Correct |
992 ms |
45208 KB |
Output is correct |
5 |
Correct |
733 ms |
45252 KB |
Output is correct |
6 |
Correct |
659 ms |
45324 KB |
Output is correct |
7 |
Correct |
16 ms |
1092 KB |
Output is correct |
8 |
Correct |
24 ms |
1092 KB |
Output is correct |
9 |
Execution timed out |
1089 ms |
45224 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
561 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1480 KB |
Output is correct |
2 |
Correct |
6 ms |
1996 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
9 ms |
4428 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
4332 KB |
Output is correct |
8 |
Correct |
10 ms |
3784 KB |
Output is correct |
9 |
Correct |
9 ms |
2124 KB |
Output is correct |
10 |
Correct |
9 ms |
3532 KB |
Output is correct |
11 |
Correct |
9 ms |
2892 KB |
Output is correct |
12 |
Correct |
9 ms |
1996 KB |
Output is correct |
13 |
Correct |
10 ms |
2476 KB |
Output is correct |
14 |
Correct |
14 ms |
2636 KB |
Output is correct |
15 |
Correct |
10 ms |
2636 KB |
Output is correct |
16 |
Correct |
17 ms |
2724 KB |
Output is correct |
17 |
Correct |
5 ms |
1352 KB |
Output is correct |
18 |
Correct |
9 ms |
1864 KB |
Output is correct |
19 |
Correct |
2 ms |
1392 KB |
Output is correct |
20 |
Correct |
2 ms |
1612 KB |
Output is correct |
21 |
Correct |
931 ms |
45292 KB |
Output is correct |
22 |
Correct |
712 ms |
45332 KB |
Output is correct |
23 |
Correct |
865 ms |
45304 KB |
Output is correct |
24 |
Correct |
992 ms |
45208 KB |
Output is correct |
25 |
Correct |
733 ms |
45252 KB |
Output is correct |
26 |
Correct |
659 ms |
45324 KB |
Output is correct |
27 |
Correct |
16 ms |
1092 KB |
Output is correct |
28 |
Correct |
24 ms |
1092 KB |
Output is correct |
29 |
Execution timed out |
1089 ms |
45224 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
681 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1480 KB |
Output is correct |
2 |
Correct |
6 ms |
1996 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
9 ms |
4428 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
4332 KB |
Output is correct |
8 |
Correct |
10 ms |
3784 KB |
Output is correct |
9 |
Correct |
9 ms |
2124 KB |
Output is correct |
10 |
Correct |
9 ms |
3532 KB |
Output is correct |
11 |
Correct |
9 ms |
2892 KB |
Output is correct |
12 |
Correct |
9 ms |
1996 KB |
Output is correct |
13 |
Correct |
10 ms |
2476 KB |
Output is correct |
14 |
Correct |
14 ms |
2636 KB |
Output is correct |
15 |
Correct |
10 ms |
2636 KB |
Output is correct |
16 |
Correct |
17 ms |
2724 KB |
Output is correct |
17 |
Correct |
5 ms |
1352 KB |
Output is correct |
18 |
Correct |
9 ms |
1864 KB |
Output is correct |
19 |
Correct |
2 ms |
1392 KB |
Output is correct |
20 |
Correct |
2 ms |
1612 KB |
Output is correct |
21 |
Runtime error |
710 ms |
524292 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1480 KB |
Output is correct |
2 |
Correct |
6 ms |
1996 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
9 ms |
4428 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
4332 KB |
Output is correct |
8 |
Correct |
10 ms |
3784 KB |
Output is correct |
9 |
Correct |
9 ms |
2124 KB |
Output is correct |
10 |
Correct |
9 ms |
3532 KB |
Output is correct |
11 |
Correct |
9 ms |
2892 KB |
Output is correct |
12 |
Correct |
9 ms |
1996 KB |
Output is correct |
13 |
Correct |
10 ms |
2476 KB |
Output is correct |
14 |
Correct |
14 ms |
2636 KB |
Output is correct |
15 |
Correct |
10 ms |
2636 KB |
Output is correct |
16 |
Correct |
17 ms |
2724 KB |
Output is correct |
17 |
Correct |
5 ms |
1352 KB |
Output is correct |
18 |
Correct |
9 ms |
1864 KB |
Output is correct |
19 |
Correct |
2 ms |
1392 KB |
Output is correct |
20 |
Correct |
2 ms |
1612 KB |
Output is correct |
21 |
Runtime error |
710 ms |
524292 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |