QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#557170 | #9240. Mosaic | zhouhuanyi# | 0 | 0ms | 0kb | C++17 | 1.4kb | 2024-09-11 07:41:29 | 2024-09-11 07:41:29 |
answer
#include "mosaic.h"
#include<iostream>
#include<cstdio>
#include<vector>
#define N 200000
using namespace std;
int n,s[N+1],s2[N+1],s3[N+1],s4[N+1];
int calc(int x,int y)
{
return (!x)&&(!y);
}
vector<int>p[N+1];
long long solve(int x,int y)
{
if (x<0||y<0) return 0;
long long res=0;
if (x>=0) res+=s[y];
if (y>=0) res+=s2[x];
if (x>=1) res+=s3[y];
if (y>=1) res+=s4[x];
if (x>=2)
{
for (int i=2;i<=y;++i)
if (p[2][i])
res+=min(x-2+1,y-i+1);
}
if (y>=2)
{
for (int i=3;i<=x;++i)
if (p[i][2])
res+=min(x-i+1,y-2+1);
}
return res;
}
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){
vector<long long>C(T.size());
n=X.size();
for (int i=0;i<n;++i)
{
if (i<=2) p[i].push_back(n);
else p[i].push_back(3);
}
for (int i=0;i<n;++i) p[0][i]=X[i],p[i][0]=Y[i];
for (int i=1;i<n;++i)
for (int j=1;j<((i<=2)?n:3);++j)
p[i][j]=calc(p[i-1][j],p[i][j-1]);
s[0]=p[0][0];
for (int i=1;i<n;++i) s[i]=s[i-1]+p[0][i],s2[i]=s2[i-1]+p[i][0];
s3[1]=p[1][1];
for (int i=2;i<n;++i) s3[i]=s3[i-1]+p[1][i],s4[i]=s4[i-1]+p[i][1];
for (int i=0;i<T.size();++i) C[i]=solve(B[i],R[i])-solve(T[i]-1,R[i])-solve(B[i],L[i]-1)+solve(T[i]-1,L[i]-1);
return C;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 1 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Runtime Error
Test #18:
score: 0
Runtime Error
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199999 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 1 0 0 0 0 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK
result:
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Runtime Error
Test #31:
score: 0
Runtime Error
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 200000 1 7 0 4 3 4 3 4 3 6 2 5 4 5 6 7 5 7 2 8 0 6 4 7 0 5 6 7 1 3 9 9 6 9 1 7 2 9 4 6 4 4 6 7 0 1 8 8 7 7 0 3 0 4 1 7 2 2 0 9 3 9 4 6 3 9 0 9 1 8 4 6 4 5 5 7 0 6 2 3 2 3 0 6 1 9 8 8 2 4 3 4 3 6 2 9 3 9 2 7 1 3 0 3 0 8 2 4 3...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 13 2 6 2 9 11 5 1 12 11 1 0 1 13 4 9 29 10 3 5 6 4 3 14 18 5 10 5 7 9 12 3 6 3 5 14 6 3 6 7 14 21 2 4 9 6 14 2 4 11 4 8 20 1 2 5 6 4 1 4 3 3 4 4 16 29 8 1 6 7 4 12 11 7 4 4 8 4 4 15 7 11 7 2 2 7 19 2 2 2 5 12 19 12 7 1 2 2 3 15 18 6 2 5 3 12 14 8 33 6 6 7 8 8 13 4...
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #42:
score: 0
Time Limit Exceeded
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199999 0 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 1 0 1 ...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%