QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140314#6563. Four Squaresmosp#WA 1ms3544kbC++231.1kb2023-08-15 17:33:002023-08-15 17:33:02

Judging History

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

  • [2023-08-15 17:33:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3544kb
  • [2023-08-15 17:33:00]
  • 提交

answer

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

bool check(vector<pair<int, int>> &v) {
    if(v[0].second == v[1].second && v[2].second == v[3].second && v[0].first + v[1].first == v[2].first + v[3].first && v[0].first + v[1].first == v[0].second + v[2].second) return true;
    if(v[0].second == v[1].second && v[1].second == v[2].second && v[0].first + v[1].first + v[2].first == v[3].first && v[0].second + v[3].second == v[3].first) return true;
    return false;
}

int main() {
    vector<pair<int, int>> v(4);
    for(int i = 0; i < 4; i++) {
        cin >> v[i].first >> v[i].second;
    }
    bool pos = false;
    sort(v.begin(), v.end());
    do {
        for(int m = 0; m < 16; m++) {
            for(int i = 0; i < 4; i++) {
                if((m >> i) & 1) {
                    swap(v[i].first, v[i].second);
                }
            }
            pos |= check(v);
            for(int i = 0; i < 4; i++) {
                if((m >> i) & 1) {
                    swap(v[i].first, v[i].second);
                }
            }
        }
    } while(next_permutation(v.begin(), v.end()));
    cout << (pos ? 1 : 0) << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3436kb

input:

2 8
2 8
2 8
2 8

output:

0

result:

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