QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111041 | #6563. Four Square | OOBMABTRAMS# | WA | 2ms | 3496kb | C++17 | 1.3kb | 2023-06-05 17:06:20 | 2023-06-05 17:06:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
typedef long long ll;
typedef long double ld;
int input=0;
const ll inf=2e18;
const int N=4;
int S,n;
int a[N],b[N];
int g[3013][3013];
pair<int,int>find(){
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(!g[i][j])return {i,j};
}
int vis[N];
void dfs(int xx,int cnt){
vis[xx]=1;
auto[x,y]=find();
int f=1;
if(x+a[xx]-1>n||y+b[xx]-1>n)return;
for(int i=x;i<x+a[xx]&&f;i++)for(int j=y;j<y+b[xx]&&f;j++)if(g[i][j])f=0;
if(!f)return;
for(int i=x;i<x+a[xx];i++)for(int j=y;j<y+b[xx];j++)g[i][j]=1;
for(int i:{1,2,3,4})for(int p:{0,1})if(!vis[i]){
swap(a[i],b[i]);
dfs(i,cnt+1);
}
if(cnt==4){
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(!g[i][j])return;
cout<<1<<'\n';
exit(0);
}
for(int i=x;i<x+a[xx];i++)for(int j=y;j<y+b[xx];j++)g[i][j]=0;
}
void solve(){
for(int i=0;i<N;i++)cin>>a[i]>>b[i],S+=a[i]*b[i];
for(int i=1;i<=2000;i++)if(S==i*i)n=i;
if(!n){
cout<<0<<'\n';
return;
}
dfs(0,1);
cout<<0<<'\n';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cout<<fixed<<setprecision(10);
int T;
if(input)cin>>T;else T=1;
for(int tc=1;tc<=T;tc++)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3468kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3360kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3496kb
input:
2 8 2 8 2 8 2 8
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'