#include "mosaic.h"
#define pb push_back
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200005;
//pref[maxn][maxn];
int n;
vector < int > a[maxn];
std::vector<long long> mosaic(std::vector<int> X, std::vector<int> Y,
std::vector<int> T, std::vector<int> B,
std::vector<int> L, std::vector<int> R)
{
int q = (int)T.size();
std::vector<long long> C(q, 0);
n = X.size();
a[0].resize(n+1, 0);
a[1].resize(n+1, 0);
a[2].resize(n+1, 0);
a[3].resize(n+1, 0);
a[4].resize(n+1, 0);
for (int j = 5; j <= n; ++ j)
a[j].resize(6, 0);
for (int i = 1; i <= n; ++ i)
a[1][i] = X[i-1];
for (int i = 1; i <= n; ++ i)
a[i][1] = Y[i-1];
for (int i = 2; i <= 4; ++ i)
{
for (int j = i; j <= n; ++ j)
{
if(!a[i-1][j] && !a[i][j-1])a[i][j] = 1;
else a[i][j] = 0;
}
for (int j = i; j <= n; ++ j)
{
if(!a[j-1][i] && !a[j][i-1])a[j][i] = 1;
else a[j][i] = 0;
}
}
q = (int)T.size();
//std::vector<long long> C(q, 0);
vector < long long > res;
for (int i = 0; i < q; ++ i)
{
int t = T[i] + 1;
int b = B[i] + 1;
int l = L[i] + 1;
int r = R[i] + 1;
t = max(2, t);
l = max(2, l);
//cout << t << " " << b << endl;
// cout << l << " " << r << endl;
if(l > r || t > b)res.pb(0);
else
{
// cout << "here " << endl;
//cout << t << " " << b << endl;
//cout << l << " " << r << endl;
if((t & 1) == (l & 1))
{
long long szl = r - l + 1;
long long szt = b - t + 1;
long long more_cols = (szl + 1)/2;
long long more_rows = (szt + 1)/2;
long long less_rows = szt - more_rows;
long long less_cols = szl - more_cols;
res.pb(more_cols * more_rows + less_rows * less_cols);
}
else
{
long long szl = r - l + 1;
long long szt = b - t + 1;
long long more_cols = (szl)/2;
long long more_rows = (szt)/2;
long long less_rows = szt - more_rows;
long long less_cols = szl - more_cols;
res.pb(more_cols * more_rows + less_rows * less_cols);
}
}
}
return res;
}
/**
4
1 0 1 0
1 1 0 1
2
0 3 0 3
2 3 0 2
*/
# | 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... |