QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#111041#6563. Four SquareOOBMABTRAMS#WA 2ms3496kbC++171.3kb2023-06-05 17:06:202023-06-05 17:06:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-05 17:06:22]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3496kb
  • [2023-06-05 17:06:20]
  • 提交

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();
}

详细

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'