QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#188917 | #6563. Four Square | ucup-team870# | WA | 1ms | 3476kb | C++14 | 1.9kb | 2023-09-26 16:45:18 | 2023-09-26 16:45:18 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
struct P{
int x,y;
};
#define vp vector<P>
bool ck2(vp q,int X,int Y){
// cout<<X<<' '<<Y<<endl;
// for(auto [x,y]:q)cout<<x<<' '<<
int v1[2]={q[0].x,q[0].y},v2[2]={q[1].x,q[1].y};
rep(i,0,1){
rep(j,0,1){
if(v1[i]!=v2[j])continue;
int x=v1[i],y=v1[1-i]+v2[1-j];
if((x==X && y==Y) && (x==Y && y==X))return true;
}
}
return false;
}
bool ck3(vp q,int X,int Y){
// for(auto [x,y]:q){
// cout<<x<<' '<<y<<'\n';
// }
rep(i,0,2){
vp qi; rep(j,0,2){if(j!=i)qi.push_back(q[j]);}
int v[2]={q[i].x,q[i].y}; int b[2]={X,Y};
rep(j,0,1){
rep(k,0,1){
if(v[j]==b[k]){
if(ck2(qi, v[j],b[1-k]-v[1-j]))return true;
}
}
}
}
return false;
}
P a[4]; int L;
P q[4]; int vis[4];
void dfs(int i){
if(i==4){
rep(j,0,3){
if(q[j].x+q[(j+1)%4].y!=L)return;
}
cout<<1; exit(0);
}
rep(j,0,3){
if(!vis[j]){
q[i]=a[j]; vis[j]=1;
dfs(i+1); vis[j]=0;
q[i]={a[j].y,a[j].x}; vis[j]=1;
dfs(i+1); vis[j]=0;
}
}
}
int main() {
IOS
int s=0;
rep(i,0,3){
cin>>a[i].x>>a[i].y;
if(a[i].x<a[i].y)swap(a[i].x,a[i].y);
s+=a[i].x*a[i].y;
}
L=sqrt(s)+2;
while(L*L>s)--L;
if(L*L!=s){
cout<<0; return 0;
}
rep(i,0,3){
if(a[i].x==L){
vp q;
rep(j,0,3){
if(i!=j)q.push_back(a[j]);
}
if(ck3(q,L,L-a[i].y))cout<<1; else cout<<0; return 0;
}
}
dfs(0);
cout<<0;
}
/*
6 2
4 2
4 3
4 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3476kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3436kb
input:
2 8 2 8 2 8 2 8
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'