QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#151154 | #6806. Landlord | LFCode# | WA | 16ms | 3684kb | C++14 | 2.7kb | 2023-08-26 15:37:20 | 2023-08-26 15:37:21 |
Judging History
answer
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#define int long long
using namespace std;
int x[5],y[5];
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))
int chk(int x1,int y1,int x2,int y2){
if(x1==x2){
if(x1==x[1]&&(y1>=y[1]&&y1<=y[2])&&(y2>=y[1]&&y2<=y[2]))return true;
if(x1==x[2]&&(y1>=y[1]&&y1<=y[2])&&(y2>=y[1]&&y2<=y[2]))return true;
if(x1==x[3]&&(y1>=y[3]&&y1<=y[4])&&(y2>=y[3]&&y2<=y[4]))return true;
if(x1==x[4]&&(y1>=y[3]&&y1<=y[4])&&(y2>=y[3]&&y2<=y[4]))return true;
}
if(y1==y2){
if(y1==y[1]&&(x1>=x[1]&&x1<=x[2])&&(x2>=x[1]&&x2<=x[2]))return true;
if(y1==y[2]&&(x1>=x[1]&&x1<=x[2])&&(x2>=x[1]&&x2<=x[2]))return true;
if(y1==y[3]&&(x1>=x[3]&&x1<=x[4])&&(x2>=x[3]&&x2<=x[4]))return true;
if(y1==y[4]&&(x1>=x[3]&&x1<=x[4])&&(x2>=x[3]&&x2<=x[4]))return true;
}
return false;
}
bool solve(){
map<int,vector<int> >mpx,mpy;
mpx.clear();mpy.clear();
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(chk(lst,ll,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(chk(ll,lst,*it,lst))ce++;
ll=*it;
}
}
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);
return true;
}
signed main(){
// freopen("data.in","r",stdin);
int T=read();
while(T--)solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3680kb
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:
3 4 2
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 16ms
memory: 3684kb
input:
10000 399413444 601729739 838979329 605646850 176742602 192902430 399413444 601729739 19226489 2915752 27806715 977516728 4075670 1872865 19226489 925008461 45547871 393001695 58201503 713825285 18241876 197851829 45547871 713825285 237513514 504913958 868997719 543598899 134432693 110279295 2375135...
output:
3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 3 3 4 3 3 4 3 3 4 3 3 4 4 3 3 5 3 3 4 3 2 5 4 3 5 4 3 3 6 3 3 4 4 5 3 3 4 3 4 3 3 3 3 3 4 3 4 3 2 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 4 3 3 5 3 3 4 4 5 3 3 4 3 4 3 3 3 3 3 4 4 4 4 4 4 4 4 3 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 5 6 3 4 5 ...
result:
wrong answer 43rd lines differ - expected: '3', found: '2'