QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#208004 | #6563. Four Square | Thallium54# | WA | 0ms | 3656kb | C++20 | 2.1kb | 2023-10-09 03:14:33 | 2023-10-09 03:14:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
vector<array<int, 2>> a(4);
int area = 0;
for (auto &[x, y] : a) {
cin >> x >> y;
area += x * y;
}
int sq = sqrt(area) + 5;
while (sq * sq > area)
sq--;
if (sq * sq != area) {
cout << "0\n";
return 0;
}
auto check = [sq](vector<array<int, 2>> a) {
sort(begin(a), end(a));
do {
if (a[0][1] == sq && a[3][1] == sq && a[1][0] == a[2][0] &&
a[1][1] + a[2][1] == sq && a[0][0] + a[1][0] + a[3][0] == sq) {
return true;
}
if (a[2][1] == sq && a[3][1] == sq && a[1][0] == a[0][0] &&
a[1][1] + a[0][1] == sq && a[0][0] + a[2][0] + a[3][0] == sq) {
return true;
}
if (a[0][0] == a[2][0] && a[1][0] == a[3][0] && a[0][0] + a[1][0] == sq &&
a[0][1] + a[2][1] == sq && a[1][1] + a[3][1] == sq) {
return true;
}
if (a[3][1] == sq && a[3][0] + a[2][0] == sq &&
a[0][0] + a[1][0] == a[2][0] && a[0][1] == a[1][1] &&
a[0][1] + a[2][1] == sq) {
return true;
}
if (a[3][1] == sq && a[0][0] == a[1][0] && a[0][0] == a[2][0] &&
a[0][0] + a[3][0] == sq && a[0][1] + a[1][1] + a[2][1] == sq) {
return true;
}
} while (next_permutation(begin(a), end(a)));
return false;
};
for (int msk = 0; msk < (1 << 4); msk++) {
for (int b = 0; b < 4; b++) {
if (msk >> b & 1) {
swap(a[b][0], a[b][1]);
}
}
if (check(a)) {
cout << "1\n";
return 0;
}
for (int b = 0; b < 4; b++) {
if (msk >> b & 1) {
swap(a[b][0], a[b][1]);
}
}
}
cout << 0 << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
input:
2 8 2 8 2 8 2 8
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'