QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#349112#6563. Four SquarejanY#WA 1ms3824kbC++203.0kb2024-03-09 23:40:042024-03-09 23:40:04

Judging History

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

  • [2024-03-09 23:40:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-03-09 23:40:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

vector<pair<int,int>> g;

bool attmpt(){
    int area = 0;
    for (auto &i : g){
        area += i.first*i.second;
    }
    int side = sqrt(area);
    if (side*side != area) return 0;

    int top = 0;
    for (auto &i : g) {
        top += i.first;
    }
    if (top == side){
        bool isgood = true;
        for (auto &i : g){
            if (i.second != side) isgood = false;
        }
        if (isgood) return 1;
    }

    if (top == side*2){
        for (int i = 0; i < 16; i++){
            int s1 = 0;
            int s2 = 0;
            int s1o = -1000000;
            int s2o = -1000000;
            bool isgood = true;
            for (int j = 0; j < 4; j++){
                if (i&(1<<j)){ // s1
                    s1 += g[j].first;
                    if (s1o < 0) s1o = g[j].second;
                    else {
                        if (s1o != g[j].second) isgood = false;
                    }
                } else { // s2
                    s2 += g[j].first;
                    if (s2o < 0) s2o = g[j].second;
                    else {
                        if (s2o != g[j].second) isgood = false;
                    }
                }
            }
            if (s1o + s2o != side) isgood = false;
            if (s1 != side || s2 != side) isgood = false;
            if (isgood) return 1;
        }
    }

    if (top == side*3){
        bool isgood = true;
        int bcnt = 0;
        int oth = 0;
        int lf = 0;
        int othz = -100000;
        for (auto &i : g){
            if (i.first == side){
                bcnt++;
                lf += i.second;
            } else {
                oth += i.first;
                if (othz < 0){
                    othz = i.second;
                } else {
                    if (othz != i.second) isgood = false;
                }
            }
        }
        if (othz+lf != side) isgood = false;
        if (bcnt != 2) isgood = false;
        if (isgood) return 1;
    }

    if (top == side*4){
        bool isgood = true;
        int lf = 0;
        for (auto &i : g){
            if (i.first != side) isgood = false;
            lf += i.second;
        }
        if (lf != side) isgood = false;
        if (isgood) return 1;
    }

    return 0;
}

void solve(){
    long long d, n;
    vector<pair<int,int>> z(4);
    for (int i = 0; i < 4; i++){
        cin >> z[i].first >> z[i].second;
    }

    for (int i = 0; i < 16; i++){
        g = z;
        for (int j = 0; j < 4; j++){
            if (i&(1<<j)) swap(g[j].first, g[j].second);
        }
        //for (auto &i : g){
         //   cout << i.first << ":" << i.second << " ";
        //}
        //cout << "\n";
        bool good = attmpt();
        if (good){
            cout << 1;
            return;
        }
    }
    cout << 0;
}

int main(){

    int t = 1;
    for (int i = 0; i < t; i++) solve();

    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3488kb

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3748kb

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

2 8
2 8
2 8
2 8

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

5 3
5 5
3 3
3 5

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

1 2
4 8
16 32
64 128

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

4 4
2 1
4 4
2 1

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

995 51
559 565
154 536
56 780

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

391 694
540 42
240 937
691 246

output:

0

result:

ok single line: '0'

Test #9:

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

input:

519 411
782 710
299 45
21 397

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

96 960
948 18
108 82
371 576

output:

0

result:

ok single line: '0'

Test #11:

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

input:

3 2
4 3
3 1
1 4

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

4 3
1 2
4 4
3 2

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

4 4
1 3
5 4
2 5

output:

0

result:

ok single line: '0'

Test #14:

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

input:

1000 1000
1000 1000
1000 1000
1000 1000

output:

1

result:

ok single line: '1'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

1000 999
998 1000
997 1000
997 997

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

1 3
3 3
3 3
4 7

output:

1

result:

ok single line: '1'

Test #17:

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

input:

2 5
5 4
7 1
6 2

output:

0

result:

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