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 <vector>
#include<bits/stdc++.h>
using namespace std;
const int N=5055;
#define ll long long
#define pb push_back
ll a[N][N];
ll ps[N][N];
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 n=X.size();
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++){
if(a[i][j-1]+a[i-1][j]==0)a[i][j]=1;
else a[i][j]=0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
ps[i][j]=ps[i-1][j]+ps[i][j-1]-ps[i-1][j-1]+a[i-1][j-1];
}
}
int Q = (int)T.size();
vector<ll>ans;
for(int f=0;f<Q;f++){
int x=T[f],y=B[f],l=L[f],r=R[f];
y++;
r++;
ll g= ps[y][r]-ps[y][l]-ps[x][r]+ps[x][l];
ans.pb(g);
}
return ans;
}
# | 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... |