QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#557175#9240. Mosaiczhouhuanyi#5 2ms11700kbC++171.4kb2024-09-11 07:45:432024-09-11 07:45:44

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 07:45:44]
  • 评测
  • 测评结果:5
  • 用时:2ms
  • 内存:11700kb
  • [2024-09-11 07:45:43]
  • 提交

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];
	if (n>=2)
	{
		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: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 9912kb

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:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #2:

score: 5
Accepted
time: 2ms
memory: 10756kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
1
1
1
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:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
1
1
1
1
1
1
1
1
1

result:

ok 

Test #3:

score: 5
Accepted
time: 1ms
memory: 9908kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
1 0
1 0
10
1 1 0 1
1 1 0 1
0 0 0 0
0 1 0 1
0 1 0 1
1 1 0 0
0 1 0 1
0 1 1 1
1 1 0 1
0 0 0 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
1
1
2
2
0
2
1
1
1

result:

ok 

Test #4:

score: 5
Accepted
time: 2ms
memory: 11700kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
1 0
1 0
10
0 1 1 1
0 1 0 1
0 1 0 0
1 1 0 1
0 1 0 1
0 1 0 0
1 1 1 1
0 0 0 1
0 1 0 0
1 1 0 0

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
1
2
1
1
2
1
1
1
1
0

result:

ok 

Test #5:

score: 5
Accepted
time: 2ms
memory: 9716kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
0 1
0 0
10
0 1 0 0
0 0 0 1
0 1 0 0
0 0 0 0
1 1 1 1
0 1 0 0
0 0 0 1
0 1 0 1
0 1 0 1
0 1 0 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
1
0
0
0
0
1
1
1
1

result:

ok 

Test #6:

score: 5
Accepted
time: 0ms
memory: 10656kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
1 1
1 0
10
0 0 0 1
0 0 0 1
1 1 0 1
0 1 0 1
0 1 0 0
0 1 1 1
1 1 0 1
0 0 1 1
0 1 0 0
0 1 0 0

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
2
2
0
2
1
1
0
1
1
1

result:

ok 

Test #7:

score: 5
Accepted
time: 1ms
memory: 8884kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
0 0
0 1
10
0 0 0 0
0 1 0 1
0 1 0 1
0 1 0 1
0 1 1 1
0 0 1 1
0 0 0 1
0 1 0 0
1 1 0 1
1 1 0 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
0
1
1
1
0
0
0
1
1
1

result:

ok 

Test #8:

score: 5
Accepted
time: 2ms
memory: 9764kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
1 0
1 1
10
0 1 0 0
1 1 0 1
0 0 0 1
1 1 1 1
1 1 0 0
0 1 1 1
0 1 0 0
0 0 1 1
1 1 0 1
0 1 0 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
2
1
1
0
1
0
2
0
1
2

result:

ok 

Test #9:

score: 5
Accepted
time: 1ms
memory: 8764kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
0 1
0 1
10
0 1 0 1
0 1 0 1
1 1 1 1
0 1 0 1
0 0 1 1
0 1 0 1
0 1 1 1
0 0 0 0
0 1 0 0
0 1 0 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
2
2
0
2
1
2
1
0
1
2

result:

ok 

Test #10:

score: 5
Accepted
time: 0ms
memory: 10456kb

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
2
1 1
1 1
10
0 0 0 1
0 1 0 0
0 1 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 1 0 1
0 1 1 1
0 1 0 1
1 1 1 1

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK
2
2
2
3
1
3
3
1
3
0

result:

ok 

Subtask #2:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Test #11:

score: 0
Runtime Error

input:

njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq
199
0 0 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1...

output:

Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9
OK

result:


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:

100%
Accepted

Dependency #2:

0%