# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1103547 |
2024-10-21T08:25:57 Z |
duckindog |
Mosaic (IOI24_mosaic) |
C++17 |
|
1000 ms |
1618964 KB |
#include <bits/stdc++.h>
#ifndef LOCAL
#include "mosaic.h"
#endif
using namespace std;
int cal(int x, int y) { return (x | y) ^ 1; };
vector<long long> mosaic(vector<int> X, vector<int> Y,
vector<int> T, vector<int> B,
vector<int> L, vector<int> R) {
int n = X.size();
int q = (int)T.size();
vector<long long> C(q, 0);
vector<vector<int>> a(n, vector<int>(n)), d = a;
for (int i = 0; i < n; ++i) {
a[0][i] = X[i];
a[i][0] = Y[i];
}
for (int i = 1; i < n; ++i) {
for (int j = 1; j < n; ++j) a[i][j] = cal(a[i - 1][j], a[i][j - 1]);
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
d[i][j] = a[i][j];
if (i) d[i][j] += d[i - 1][j];
if (j) d[i][j] += d[i][j - 1];
if (i && j) d[i][j] -= d[i - 1][j - 1];
}
}
for (int i = 0; i < q; ++i) {
int t = T[i], b = B[i], l = L[i], r = R[i];
int ret = d[b][r];
if (t) ret -= d[t - 1][r];
if (l) ret -= d[b][l - 1];
if (t && l) ret += d[t - 1][l - 1];
C[i] = ret;
}
return C;
}
#ifdef LOCAL
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
int N;
assert(1 == scanf("%d", &N));
std::vector<int> X(N), Y(N);
for (int i = 0; i < N; i++)
assert(1 == scanf("%d", &X[i]));
for (int i = 0; i < N; i++)
assert(1 == scanf("%d", &Y[i]));
int Q;
assert(1 == scanf("%d", &Q));
std::vector<int> T(Q), B(Q), L(Q), R(Q);
for (int k = 0; k < Q; k++)
assert(4 == scanf("%d%d%d%d", &T[k], &B[k], &L[k], &R[k]));
fclose(stdin);
std::vector<long long> C = mosaic(X, Y, T, B, L, R);
int S = (int)C.size();
for (int k = 0; k < S; k++)
printf("%lld\n", C[k]);
fclose(stdout);
return 0;
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
1 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
504 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1196 ms |
1618964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
1 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
504 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
309 ms |
208164 KB |
Output is correct |
19 |
Correct |
293 ms |
208060 KB |
Output is correct |
20 |
Correct |
280 ms |
207672 KB |
Output is correct |
21 |
Correct |
281 ms |
207508 KB |
Output is correct |
22 |
Correct |
289 ms |
207688 KB |
Output is correct |
23 |
Correct |
98 ms |
42096 KB |
Output is correct |
24 |
Correct |
99 ms |
42312 KB |
Output is correct |
25 |
Correct |
98 ms |
42312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
9808 KB |
Output is correct |
2 |
Execution timed out |
1180 ms |
1541384 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1211 ms |
1596884 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1196 ms |
1618964 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
508 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
1 ms |
504 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Execution timed out |
1196 ms |
1618964 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |