This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "mosaic.h"
using namespace std;
typedef long long ll;
ll n, q;
vector<vector<ll>> lay, layPref;
vector<ll> stairs;
/*ll test(ll t, ll b, ll l, ll r) {
if (t == 0) t++;
if (l == 0) l++;
ll ans = (b-t+1)*(r-l+1);
if ((t-l)&1) ans = ans/2;
else ans = (ans+1)/2;
return ans;
}*/
vector<ll> mosaicNaive(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R) {
n = X.size();
q = T.size();
vector<vector<bool>> grid(n, vector<bool>(n));
for (int i = 0; i < n; i++) {
grid[0][i] = X[i];
grid[i][0] = Y[i];
}
for (int row = 1; row < n; row++) {
for (int col = 1; col < n; col++) {
grid[row][col] = !grid[row-1][col] && !grid[row][col-1];
}
}
vector<ll> res(q);
for (int k = 0; k < q; k++) {
ll ans = 0;
for (int row = T[k]; row <= B[k]; row++) {
for (int col = L[k]; col <= R[k]; col++) {
ans += grid[row][col];
}
}
res[k] = ans;
}
return res;
}
vector<ll> mosaic(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R) {
n = X.size();
q = T.size();
vector<vector<bool>> grid(n, vector<bool>(n));
for (int i = 0; i < n; i++) {
grid[0][i] = X[i];
grid[i][0] = Y[i];
}
for (int row = 1; row < n; row++) {
for (int col = 1; col < n; col++) {
grid[row][col] = !grid[row-1][col] && !grid[row][col-1];
}
}
vector<ll> res(q);
for (int k = 0; k < q; k++) {
ll ans = 0;
for (int row = T[k]; row <= B[k]; row++) {
for (int col = L[k]; col <= R[k]; col++) {
ans += grid[row][col];
}
}
res[k] = ans;
}
return res;
}
#ifdef TEST
#include "grader.cpp"
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |