QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#178691 | #6563. Four Square | neko_nyaa | WA | 0ms | 3828kb | C++20 | 1.3kb | 2023-09-14 11:12:16 | 2023-09-14 11:12:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int get_height(vector<pair<int, int>> a, int side) {
int ans1 = 0, ans2 = 0;
for (auto [x, y]: a) {
if (x == a[0].first) {
ans1 += y;
} else if (y == a[0].first) {
ans1 += x;
}
if (x == a[0].second) {
ans2 += y;
} else if (y == a[0].second) {
ans2 += x;
}
}
if (ans1 == side) return a[0].first;
if (ans2 == side) return a[0].second;
return -1;
}
void dfs(int msk, vector<pair<int, int>> a, int hei, int side) {
if (msk == 15) {
cout << "1\n";
exit(0);
}
for (int i = 0; i < 15; i++) {
if ((msk & i) != 0) continue;
vector<pair<int, int>> pp;
for (int j = 0; j < 4; j++) {
if (i & (1 << j)) pp.push_back(a[j]);
}
int h = get_height(pp, side);
if (h != -1) {
dfs(msk | i, a, hei+h, side);
}
}
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
vector<pair<int, int>> a(4);
for (int i = 0; i < 4; i++) {
cin >> a[i].first >> a[i].second;
}
int area = 0;
for (auto [x, y]: a) {
area += x*y;
}
int side = sqrtl(area);
if (side*side != area) {
cout << "0\n";
return 0;
}
for (auto [x, y]: a) {
if (x > side || y > side) {
cout << "0\n";
return 0;
}
}
dfs(0, a, 0, side);
cout << "0\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 8 2 8 2 8 2 8
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
5 3 5 5 3 3 3 5
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
1 2 4 8 16 32 64 128
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
4 4 2 1 4 4 2 1
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
995 51 559 565 154 536 56 780
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
391 694 540 42 240 937 691 246
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
519 411 782 710 299 45 21 397
output:
0
result:
ok single line: '0'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
96 960 948 18 108 82 371 576
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
3 2 4 3 3 1 1 4
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
4 3 1 2 4 4 3 2
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
4 4 1 3 5 4 2 5
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1000 1000 1000 1000 1000 1000 1000 1000
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
1000 999 998 1000 997 1000 997 997
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3824kb
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: 3556kb
input:
2 5 5 4 7 1 6 2
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'