QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#208002 | #6563. Four Square | Thallium54# | WA | 1ms | 3508kb | C++20 | 2.1kb | 2023-10-09 03:11:16 | 2023-10-09 03:11:17 |
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[2][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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3468kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3364kb
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: 3508kb
input:
2 8 2 8 2 8 2 8
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'