이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |