QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#151060#6806. LandlordLFCode#RE 0ms0kbC++142.1kb2023-08-26 15:13:432023-08-26 15:13:55

Judging History

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

  • [2023-08-26 15:13:55]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-08-26 15:13:43]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#define int long long
using namespace std;
int x[5],y[5];
map<int,vector<int> >mpx,mpy;
bool Swap(int &a,int &b){a^=b^=a^=b;return true;}
int read(){
	char ch=getchar();int nn=0,ssss=1;
	while(ch<'0'||ch>'9'){if(ch=='-')ssss*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){nn=nn*10+(ch-'0');ch=getchar();}
	return nn*ssss;
}
#define p1x(xx,yy) (((xx)==x[1]||(xx)==x[2])&&(yy)>=y[1]&&(yy)<=y[2])
#define p1y(xx,yy) (((yy)==y[1]||(yy)==y[2])&&(xx)>=x[1]&&(xx)<=x[2])
#define in1(xx,yy) (p1x(xx,yy)||p1y(xx,yy))
#define p2x(xx,yy) (((xx)==x[3]||(xx)==x[4])&&(yy)>=y[3]&&(yy)<=y[4])
#define p2y(xx,yy) (((yy)==y[3]||(yy)==y[4])&&(xx)>=x[3]&&(xx)<=x[4])
#define in2(xx,yy) (p2x(xx,yy)||p2y(xx,yy))
bool solve(){
	for(int i=1;i<=4;i++){x[i]=read();y[i]=read();}
	for(int x1=1;x1<=4;x1++)
		for(int y1=1;y1<=4;y1++){
			mpx[x[x1]].push_back(y[y1]);
			mpy[y[y1]].push_back(x[x1]);
		}
	int lst=-1,cnt=0,ce=0;
	for(map<int,vector<int> >::iterator it1=mpx.begin();it1!=mpx.end();it1++){
		if(it1->first==lst)continue;lst=it1->first;
		vector<int>vec=it1->second;
		sort(vec.begin(),vec.end());
		int ll=-1;
		for(vector<int>::iterator it=vec.begin();it!=vec.end();it++){
			if(!(in1(lst,*it)||in2(lst,*it)))continue;
			if(*it==ll)continue;cnt++;if(ll==-1){ll=*it;continue;}
			if(in1(lst,ll)&&in1(lst,*it))ce++;
			else if(in2(lst,ll)&&in2(lst,*it))ce++;
			ll=*it;
		}
	}
	for(map<int,vector<int> >::iterator it1=mpy.begin();it1!=mpy.end();it1++){
		if(it1->first==lst)continue;lst=it1->first;
		vector<int>vec=it1->second;
		sort(vec.begin(),vec.end());
		int ll=-1;
		for(vector<int>::iterator it=vec.begin();it!=vec.end();it++){
			if(!(in1(*it,lst)||in2(*it,lst)))continue;
			if(*it==ll)continue;if(ll==-1){ll=*it;continue;}
			if(in1(ll,lst)&&in1(*it,lst))ce++;
			else if(in2(ll,lst)&&in2(*it,lst))ce++;
			ll=*it;
		}
	}
	mpx.clear();mpy.clear();
	int ans=ce-cnt+2;
	if(x[2]<x[3]||x[1]>x[4]||y[2]<y[3]||y[1]>y[4])ans++;
	printf("%d\n",ans);
}
signed main(){
	int T=read();
	while(T--)solve();
}

详细

Test #1:

score: 0
Runtime Error

input:

3
0 0 1 1
2 2 3 4
1 0 3 2
0 1 2 3
0 0 1 1
0 0 1 1

output:


result: