QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729690 | #6563. Four Square | ahsoltan# | AC ✓ | 3842ms | 3768kb | C++20 | 2.6kb | 2024-11-09 17:37:37 | 2024-11-09 17:37:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
#ifdef LOCAL
auto operator<<(auto& o, auto x) -> decltype(x.first, o);
auto operator<<(auto& o, auto x) -> decltype(x.end(), o) {
o << "{";
for (int i = 0; auto y : x) o << ", " + !i++ * 2 << y;
return o << "}";
}
auto operator<<(auto& o, auto x) -> decltype(x.first, o) {
return o << "(" << x.first << ", " << x.second << ")";
}
void __print(auto... x) { ((cerr << x << " "), ...) << endl; }
#define debug(x...) __print("[" #x "]:", x)
#else
#define debug(...) 2137
#endif
bool czy(pair<int, int> p0, pair<int, int> p1, int x, int y) {
if(p0.first == p1.second) {
swap(p1.first, p1.second);
}
if(p0.second == p1.first) {
swap(p0.first, p0.second);
}
if(p0.second == p1.second) {
swap(p0.first, p0.second);
swap(p1.first, p1.second);
}
debug(p0, p1);
if(p0.first != p1.first)
return 0;
int s0 = p0.first;
int s1 = p0.second + p1.second;
if(s0 == x && s1 == y)
return 1;
if(s0 == y && s1 == x)
return 1;
return 0;
}
bool czy1(pair<int, int> p0, int x, int y) {
if(x == p0.first && y == p0.second)
return true;
if(y == p0.first && x == p0.second)
return true;
return false;
}
int main() {
debug(czy({2, 3}, {1, 3}, 3, 3));
cin.tie(0)->sync_with_stdio(0);
vector<pair<int, int>> ve(4);
int sm = 0;
for(auto &[i, j] : ve) {
cin >> i >> j;
sm += i * j;
}
int bok = sqrt(sm);
if(bok * bok != sm) {
cout << 0 << endl;
return 0;
}
bool found = 0;
for(int x = 0; x < bok; x++) {
sort(all(ve));
do {
if(czy(ve[0], ve[1], x, bok) && czy(ve[2], ve[3], bok - x, bok)) {
found = 1;
}
}
while(next_permutation(all(ve)));
}
debug(bok);
auto vv = ve;
sort(all(vv));
for(int x = 0; x <= bok; x++) {
for(int y = 0; y <= bok; y++) {
ve = vv;
vector<pair<int, int>> vv2 = {
{x, y},
{bok - x, y},
{bok, bok - y}
};
sort(all(vv2));
do {
auto v2 = vv2;
do{
bool b0 = czy1(ve[0], v2[0].first, v2[0].second);
bool b1 = czy1(ve[1], v2[1].first, v2[1].second);
bool b2 = czy(ve[2], ve[3], v2[2].first, v2[2].second);
found |= b0 & b1 & b2;
}
while(next_permutation(all(v2)));
}
while(next_permutation(all(ve)));
}
}
cout << found << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 8 2 8 2 8 2 8
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 3 5 5 3 3 3 5
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
1 2 4 8 16 32 64 128
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4 4 2 1 4 4 2 1
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 429ms
memory: 3548kb
input:
995 51 559 565 154 536 56 780
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 595ms
memory: 3768kb
input:
391 694 540 42 240 937 691 246
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 687ms
memory: 3516kb
input:
519 411 782 710 299 45 21 397
output:
0
result:
ok single line: '0'
Test #10:
score: 0
Accepted
time: 287ms
memory: 3624kb
input:
96 960 948 18 108 82 371 576
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
3 2 4 3 3 1 1 4
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
4 3 1 2 4 4 3 2
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
4 4 1 3 5 4 2 5
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 236ms
memory: 3600kb
input:
1000 1000 1000 1000 1000 1000 1000 1000
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 3842ms
memory: 3428kb
input:
1000 999 998 1000 997 1000 997 997
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1 3 3 3 3 3 4 7
output:
1
result:
ok single line: '1'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
2 5 5 4 7 1 6 2
output:
1
result:
ok single line: '1'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
12 2 12 7 7 12 16 4
output:
1
result:
ok single line: '1'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
7 2 2 14 5 14 7 12
output:
1
result:
ok single line: '1'
Test #20:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
32 36 5 1 1 37 35 5
output:
1
result:
ok single line: '1'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3460kb
input:
28 30 30 1 31 1 2 30
output:
1
result:
ok single line: '1'
Test #22:
score: 0
Accepted
time: 6ms
memory: 3628kb
input:
66 68 9 11 7 66 9 64
output:
1
result:
ok single line: '1'
Test #23:
score: 0
Accepted
time: 7ms
memory: 3516kb
input:
59 44 25 44 40 32 40 52
output:
1
result:
ok single line: '1'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
4 4 2 3 4 2 3 2
output:
1
result:
ok single line: '1'