QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#131360 | #6563. Four Square | triplem5ds# | WA | 2ms | 3584kb | C++23 | 2.0kb | 2023-07-27 00:22:43 | 2023-07-27 00:22:47 |
Judging History
answer
/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define popCnt(x) (__builtin_popcountll(x))
#define int ll
using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 1e6 + 5, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-7;
vector<ii> vp;
bool solve4(vector<ii> vp) {
f(i, 0, 4)if (vp[i].F != vp[0].F)return false;
int sum = 0;
f(i, 0, 4)sum += vp[i].S;
return vp[0].F == sum;
}
bool solve13(vector<ii> vp) {
int sum = 0;
f(i, 1, 4)sum += vp[i].S;
f(i, 1, 3)if (vp[i].F != vp[1].F)return false;
return (sum == vp[1].S && (vp[0].F + vp[1].F == vp[0].S));
}
bool solve22(vector<ii> vp) {
if (vp[0].F != vp[1].F)return false;
if (vp[2].F != vp[3].F)return false;
if (vp[0].S + vp[1].S != vp[2].S + vp[3].S)return false;
return (vp[0].F + vp[2].F == vp[0].S + vp[1].S);
}
bool calc(vector<ii> vp) {
sort(all(vp));
do {
if (solve4(vp))return true;
if (solve13(vp))return true;
if (solve22(vp))return true;
} while (next_permutation(all(vp)));
return false;
}
void doWork() {
vp.resize(4);
f(i, 0, 4) {
cin >> vp[i].F >> vp[i].S;
}
f(m, 0, 1 << 4) {
f(i, 0, 4)if (m >> i & 1)swap(vp[i].F, vp[i].S);
if (calc(vp)) {
cout << "1\n";
return;
}
f(i, 0, 4)if (m >> i & 1)swap(vp[i].F, vp[i].S);
}
cout << "0\n";
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--) {
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
2 8 2 8 2 8 2 8
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
5 3 5 5 3 3 3 5
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
1 2 4 8 16 32 64 128
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
4 4 2 1 4 4 2 1
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
995 51 559 565 154 536 56 780
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
391 694 540 42 240 937 691 246
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
519 411 782 710 299 45 21 397
output:
0
result:
ok single line: '0'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
96 960 948 18 108 82 371 576
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
3 2 4 3 3 1 1 4
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
4 3 1 2 4 4 3 2
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3452kb
input:
4 4 1 3 5 4 2 5
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
1000 1000 1000 1000 1000 1000 1000 1000
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3500kb
input:
1000 999 998 1000 997 1000 997 997
output:
1
result:
ok single line: '1'
Test #16:
score: -100
Wrong Answer
time: 1ms
memory: 3584kb
input:
1 3 3 3 3 3 4 7
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'