QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559868#8669. 正方形计数zqiaor0 3018ms4040kbC++142.2kb2024-09-12 10:03:272024-09-12 10:03:27

Judging History

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

  • [2024-09-12 10:03:27]
  • 评测
  • 测评结果:0
  • 用时:3018ms
  • 内存:4040kb
  • [2024-09-12 10:03:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define eps 1e-7
int T,n,h[2005][2],l[2005][2];
long long ans;
vector<long double>H[2005],L[2005];
struct node{int x,y;}a[10];
void solve(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
	a[0]=a[n];
	for(int i=1;i<=n;i++)
		if(a[i].x==a[i-1].x){
			for(int j=a[i-1].y;j<=a[i].y;j++)if(!H[j].size()||abs(H[j][H[j].size()-1]-a[i].x)>eps)H[j].push_back(a[i].x);
			for(int j=a[i-1].y;j>=a[i].y;j--)if(!H[j].size()||abs(H[j][H[j].size()-1]-a[i].x)>eps)H[j].push_back(a[i].x);
		}else if(a[i].y==a[i-1].y){
			for(int j=a[i-1].x;j<=a[i].x;j++)if(!L[j].size()||abs(L[j][L[j].size()-1]-a[i].y)>eps)L[j].push_back(a[i].y);
			for(int j=a[i-1].x;j>=a[i].x;j--)if(!L[j].size()||abs(L[j][L[j].size()-1]-a[i].y)>eps)L[j].push_back(a[i].y);
		}else {
			long double k=(long double)(a[i-1].y-a[i].y)/(a[i-1].x-a[i].x),b=a[i].y-k*a[i].x;
			for(int j=a[i-1].x;j<=a[i].x;j++)if(!L[j].size()||abs(L[j][L[j].size()-1]-(k*j+b))>eps)L[j].push_back(k*j+b);
			for(int j=a[i-1].x;j>=a[i].x;j--)if(!L[j].size()||abs(L[j][L[j].size()-1]-(k*j+b))>eps)L[j].push_back(k*j+b);
			for(int j=a[i-1].y;j<=a[i].y;j++)if(!H[j].size()||abs(H[j][H[j].size()-1]-(j-b)/k)>eps)H[j].push_back((j-b)/k);
			for(int j=a[i-1].y;j>=a[i].y;j--)if(!H[j].size()||abs(H[j][H[j].size()-1]-(j-b)/k)>eps)H[j].push_back((j-b)/k);
		}
	for(int i=0;i<=2000;i++){
		if(H[i].size()==1)H[i].push_back(H[i][0]);
		if(L[i].size()==1)L[i].push_back(L[i][0]);
		if(H[i].size()>=2){
			if(H[i][0]>H[i][1])swap(H[i][0],H[i][1]);
			h[i][0]=ceil(H[i][0]),h[i][1]=floor(H[i][1]);
		}else h[i][1]=-1;
		if(L[i].size()>=2){
			if(L[i][0]>L[i][1])swap(L[i][0],L[i][1]);
			l[i][0]=ceil(L[i][0]),l[i][1]=floor(L[i][1]);
		}else l[i][1]=-1;
	}
	for(int i=0;i<=2000;i++)
		for(int j=h[i][0];j<=h[i][1];j++)
			for(int k=0;i+k<=2000;k++){
				if(j<h[i+k][0]||j+k>h[i][1]||j+k>h[i+k][1])break;
				if(k==0)ans+=min({l[j][1]-i,j-h[i][0],i-l[j][0],h[i][1]-j});
				else ans+=1+min({l[j][1]-i-k,j-h[i][0],i-l[j+k][0],h[i+k][1]-j-k})+min({i-l[j][0],h[i][1]-j-k,l[j+k][1]-i-k,j-h[i+k][0]});
			}
	cout<<ans<<'\n';
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0),solve();
	return 0;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 10
Accepted
time: 3018ms
memory: 4040kb

input:

4
131 603
131 1828
1919 1828
1919 603

output:

361182910200

result:

ok 1 number(s): "361182910200"

Test #2:

score: 10
Accepted
time: 1ms
memory: 3744kb

input:

4
239 211
239 962
261 962
261 211

output:

1498772

result:

ok 1 number(s): "1498772"

Test #3:

score: 0
Time Limit Exceeded

input:

4
0 0
0 2000
2000 2000
2000 0

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 25
Accepted
time: 780ms
memory: 3984kb

input:

3
131 603
131 1828
1919 603

output:

63739309181

result:

ok 1 number(s): "63739309181"

Test #7:

score: 25
Accepted
time: 1ms
memory: 3812kb

input:

3
239 211
239 962
261 211

output:

353073

result:

ok 1 number(s): "353073"

Test #8:

score: 25
Accepted
time: 1949ms
memory: 3912kb

input:

3
0 0
0 2000
2000 0

output:

222889277611

result:

ok 1 number(s): "222889277611"

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 3884kb

input:

3
36 771
36 786
672 771

output:

98832

result:

wrong answer 1st numbers differ - expected: '98847', found: '98832'

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 15
Accepted
time: 0ms
memory: 3816kb

input:

8
0 13
4 15
15 15
15 6
13 1
12 0
5 0
0 6

output:

4047

result:

ok 1 number(s): "4047"

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 3740kb

input:

8
0 4
1 15
2 15
15 14
15 4
14 0
1 0
0 2

output:

4188

result:

wrong answer 1st numbers differ - expected: '4200', found: '4188'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%