QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#349076 | #6563. Four Square | janY# | WA | 1ms | 3820kb | C++17 | 2.8kb | 2024-03-09 23:29:17 | 2024-03-09 23:29:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> g;
bool attmpt(){
int area = 0;
for (auto &i : g){
area += i.first*i.second;
}
int side = sqrt(area);
if (side*side != area) return 0;
int top = 0;
for (auto &i : g) {
top += i.first;
}
if (top == side){
bool isgood = true;
for (auto &i : g){
if (i.second != side) isgood = false;
}
if (isgood) return 1;
}
if (top == side*2){
for (int i = 0; i < 16; i++){
int s1 = 0;
int s2 = 0;
int s1o = -1;
int s2o = -1;
bool isgood = true;
for (int j = 0; j < 4; j++){
if (i&(1<<j)){ // s1
s1 += g[j].first;
if (s1o == -1) s1o = g[j].second;
else {
if (s1o != g[j].second) isgood = false;
}
} else { // s2
s2 += g[j].first;
if (s2o == -1) s2o = g[j].second;
else {
if (s2o != g[j].second) isgood = false;
}
}
}
if (s1 != side || s2 != side) isgood = false;
if (isgood) return 1;
}
}
if (top == side*3){
bool isgood = true;
int bcnt = 0;
int oth = 0;
int lf = 0;
int othz = -1;
for (auto &i : g){
if (i.first == side){
bcnt++;
lf += i.second;
} else {
oth += i.first;
if (othz == -1){
othz = i.second;
} else {
if (othz != i.second) isgood = false;
}
}
}
if (othz+lf != side) isgood = false;
if (bcnt != 2) isgood = false;
if (isgood) return 1;
}
if (top == side*4){
bool isgood = true;
int lf = 0;
for (auto &i : g){
if (i.first != side) isgood = false;
lf += i.second;
}
if (lf != side) isgood = false;
if (isgood) return 1;
}
return 0;
}
void solve(){
long long d, n;
vector<pair<int,int>> z(4);
for (int i = 0; i < 4; i++){
cin >> z[i].first >> z[i].second;
}
for (int i = 0; i < 16; i++){
g = z;
for (int j = 0; j < 4; j++){
if (i&(1<<j)) swap(g[j].first, g[j].second);
}
bool good = attmpt();
if (good){
cout << 1;
return;
}
}
cout << 0;
}
int main(){
int t = 1;
for (int i = 0; i < t; i++) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3748kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
2 8 2 8 2 8 2 8
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
5 3 5 5 3 3 3 5
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
1 2 4 8 16 32 64 128
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
4 4 2 1 4 4 2 1
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
995 51 559 565 154 536 56 780
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
391 694 540 42 240 937 691 246
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
519 411 782 710 299 45 21 397
output:
0
result:
ok single line: '0'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
96 960 948 18 108 82 371 576
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
3 2 4 3 3 1 1 4
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
4 3 1 2 4 4 3 2
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
4 4 1 3 5 4 2 5
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1000 1000 1000 1000 1000 1000 1000 1000
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1000 999 998 1000 997 1000 997 997
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
1 3 3 3 3 3 4 7
output:
1
result:
ok single line: '1'
Test #17:
score: -100
Wrong Answer
time: 1ms
memory: 3552kb
input:
2 5 5 4 7 1 6 2
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'