#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2612 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2612 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
3 ms |
11600 KB |
Output is correct |
12 |
Correct |
3 ms |
11856 KB |
Output is correct |
13 |
Correct |
3 ms |
11600 KB |
Output is correct |
14 |
Correct |
3 ms |
11600 KB |
Output is correct |
15 |
Correct |
2 ms |
6992 KB |
Output is correct |
16 |
Correct |
2 ms |
6992 KB |
Output is correct |
17 |
Correct |
2 ms |
6992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
361 ms |
423648 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2612 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
3 ms |
11600 KB |
Output is correct |
12 |
Correct |
3 ms |
11856 KB |
Output is correct |
13 |
Correct |
3 ms |
11600 KB |
Output is correct |
14 |
Correct |
3 ms |
11600 KB |
Output is correct |
15 |
Correct |
2 ms |
6992 KB |
Output is correct |
16 |
Correct |
2 ms |
6992 KB |
Output is correct |
17 |
Correct |
2 ms |
6992 KB |
Output is correct |
18 |
Correct |
303 ms |
409028 KB |
Output is correct |
19 |
Correct |
295 ms |
409036 KB |
Output is correct |
20 |
Correct |
276 ms |
408772 KB |
Output is correct |
21 |
Correct |
286 ms |
408772 KB |
Output is correct |
22 |
Correct |
274 ms |
408772 KB |
Output is correct |
23 |
Correct |
97 ms |
148412 KB |
Output is correct |
24 |
Correct |
92 ms |
148668 KB |
Output is correct |
25 |
Correct |
94 ms |
147656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
11892 KB |
Output is correct |
2 |
Runtime error |
337 ms |
429460 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
280 ms |
188448 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
361 ms |
423648 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2612 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
3 ms |
11600 KB |
Output is correct |
13 |
Correct |
3 ms |
11856 KB |
Output is correct |
14 |
Correct |
3 ms |
11600 KB |
Output is correct |
15 |
Correct |
3 ms |
11600 KB |
Output is correct |
16 |
Correct |
2 ms |
6992 KB |
Output is correct |
17 |
Correct |
2 ms |
6992 KB |
Output is correct |
18 |
Correct |
2 ms |
6992 KB |
Output is correct |
19 |
Runtime error |
361 ms |
423648 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |