QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188912#6568. Space Alignmentucup-team870#WA 0ms3848kbC++141.8kb2023-09-26 16:35:392023-09-26 16:35:39

Judging History

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

  • [2023-09-26 16:35:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2023-09-26 16:35:39]
  • 提交

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){
    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){
    rep(i,0,2){
        vp qi; rep(j,0,2){if(j!=i)qi.push_back(q[i]);}
        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[i]);
            }
            if(ck3(q,L,L-a[i].y))cout<<1; else cout<<0; return 0;
        }
    }
    dfs(0);
    cout<<0;
}

详细

Test #1:

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

input:

10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}

output:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'