QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354812#6563. Four Squarekevinshan#WA 0ms3860kbC++172.2kb2024-03-16 02:36:132024-03-16 02:36:14

Judging History

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

  • [2024-03-16 02:36:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3860kb
  • [2024-03-16 02:36:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define i4 array<int, 4>
#define ff first
#define ss second
int x[4], y[4], a[4000][4000];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int cur = 0;
    for (int i=0; i<4; i++) cin>>x[i]>>y[i], cur += x[i] * y[i];
    int sq = sqrt(cur);
    if (sq * sq != cur) return cout<<0, 0;
    for (int i=0; i<16; i++)
    {
        vector<ii> v;
        for (int j=0; j<4; j++) if (i >> j & 1) v.push_back({y[j], x[j]}); else v.push_back({x[j], y[j]});
        sort(v.begin(), v.end());
        do
        {  
            bool f = 1;
            vector<i4> ve;
            for (auto [x, y]: v)
            {
                /* Find upmost line */
                int xx = -1, yy = -1;
                for (int i=0; i<sq; i++)
                {
                    int curcol = 0;
                    for (auto rec: ve)
                    {
                        if (rec[0] <= i && rec[2] > i && rec[1] <= curcol && rec[3] > curcol) 
                            curcol = max(curcol, rec[3]);
                    }
                    if (curcol < sq) 
                    {
                        xx = i;
                        yy = curcol;
                        break;
                    }
                }
                assert(xx != -1);
                // cout<<"HEH: "<<xx<<" "<<yy<<"\n";
                if (xx + x > sq || yy + y > sq)
                {
                    f = 0;
                    break;
                }
                ve.push_back({xx, yy, xx+x, yy+y});
                sort(ve.begin(), ve.end());
                // for (auto x: ve) cout<<"BRUH: "<<x[0]<<" "<<x[1]<<" "<<x[2]<<" "<<x[3]<<"\n";
            }
            if (f) 
            {
                // for (auto [x, y]: v) cout<<"HUH: "<<x<<" "<<y<<"\n";
                // for (auto x: ve) cout<<"BRUH: "<<x[0]<<" "<<x[1]<<" "<<x[2]<<" "<<x[3]<<"\n";
                return cout<<1, 0;
            }
            break;
        } while (next_permutation(v.begin(), v.end()));
        
    }
    cout<<0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

2 8
2 8
2 8
2 8

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

5 3
5 5
3 3
3 5

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1 2
4 8
16 32
64 128

output:

0

result:

ok single line: '0'

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3564kb

input:

4 4
2 1
4 4
2 1

output:

1

result:

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