QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#753045 | #8779. Square of Triangles | cyj888 | WA | 18ms | 3760kb | C++11 | 7.6kb | 2024-11-16 11:04:17 | 2024-11-16 11:04:18 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define gt()
#define ott(i, l, r) for (register int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (register int i = (r); i >= (l); i --)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
int read () {
int x = 0; bool f = false; char c = getchar ();
while (!isdigit (c)) f |= (c == '-'), c = getchar ();
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
return f ? -x : x;
}
const int N = 1100, mod = 1e9 + 7;
const ld eps = 1e-6;
int T; int l2[5][4], id[5];
ld p, s;
ld ib[5][4];
ld sl, xl; ld l[5][4];
inline bool cmp (const ld &a1, const ld &a2) {
return fabs (a1 - a2) <= eps;
}
inline bool irt (ld* jb) {
return cmp (jb[1] * jb[1] + jb[2] * jb[2], jb[3] * jb[3]);
}
//level 0
inline bool test1 () {
if (irt (ib[1]) || irt (ib[2]) || irt (ib[3]) || irt (ib[4])) return false;
return cmp (ib[1][3], sl) && cmp (ib[2][3], sl) && cmp (ib[3][3], sl) && cmp (ib[4][3], sl) && cmp (ib[1][2], ib[2][1]) && cmp (ib[2][2], ib[3][1]) && cmp (ib[3][2], ib[4][1]) && cmp (ib[4][2], ib[1][1]);
}
inline bool test2 () {
if (!cmp (ib[1][1] + ib[3][2], xl) || !cmp (ib[2][1] + ib[4][2], xl)) return false;
return cmp (ib[1][3], sl) && cmp (ib[2][3], sl) && cmp (ib[3][3], sl) && cmp (ib[4][3], sl) && cmp (ib[1][2], ib[3][1]) && cmp (ib[2][2], ib[4][1]) && cmp (ib[1][1] + ib[3][2], ib[2][1] + ib[4][2]);
}
//level 1
inline bool test3 () {
if (!irt (ib[2]) || !irt (ib[3])) return false;
return cmp (ib[1][1] + ib[2][1], sl) && cmp (ib[2][2] + ib[3][2], sl) && cmp (ib[3][1], sl) && cmp (ib[1][3], ib[4][1]) && cmp (ib[2][3], ib[4][2]) && cmp (ib[3][3], ib[4][3]);
}
inline bool test4 () {
if (!irt (ib[2])) return false;
return cmp (ib[1][1] + ib[2][1], sl) && cmp (ib[2][2], sl) && cmp (ib[3][1], sl) && cmp (ib[4][1] + ib[3][2], ib[1][3]) && cmp (ib[3][3], ib[4][2]) && cmp (ib[2][3], ib[4][3]);
}
inline bool test5 () {
if (!irt (ib[2])) return false;
return cmp (ib[1][1] + ib[4][1] + ib[2][1], sl) && cmp (ib[2][2], sl) && cmp (ib[3][1], sl) && cmp (ib[3][2], ib[1][3]) && cmp (ib[3][3], ib[4][3]) && cmp (ib[2][3], ib[4][2]);
}
inline bool test6 () {
if (!irt (ib[4])) return false;
return cmp (ib[1][1] + ib[3][1], sl) && cmp (ib[2][1] + ib[4][1], sl) && cmp (ib[4][2], sl) && cmp (ib[1][3], ib[2][3]) && cmp (ib[2][2], ib[3][2]) && cmp (ib[3][3], ib[4][3]);
}
inline bool test7 () {
if (!irt (ib[4])) return false;//no xl
return cmp (ib[1][1] + ib[2][1] + ib[3][1], sl) && cmp (ib[4][1], sl) && cmp (ib[4][2], sl) && cmp (ib[1][3], ib[2][2]) && cmp (ib[2][3], ib[3][2]) && cmp (ib[3][3], ib[4][3]);
}
inline bool test8 () {
if (!irt (ib[4]) || !cmp (ib[3][3], xl)) return false;
return cmp (ib[1][1] + ib[2][1], sl) && cmp (ib[3][1] + ib[4][1], sl) && cmp (ib[4][2], sl) && cmp (ib[1][3], ib[2][2]) && cmp (ib[2][3], ib[3][3]) && cmp (ib[3][2], ib[4][3]);
}
inline bool test9 () {//irt?
return cmp (ib[1][1] + ib[2][2], sl) && cmp (ib[4][3], sl) && cmp (ib[3][3], sl) && cmp (ib[2][1] + ib[3][1], ib[1][3]) && cmp (ib[2][3], ib[4][1]) && cmp (ib[3][2], ib[4][2]);
}
inline bool test10 () {
if (!irt (ib[2])) return false;
return cmp (ib[1][1] + ib[2][2], sl) && cmp (ib[2][1] + ib[3][1], sl) && cmp (ib[4][3], sl) && cmp (ib[1][3], ib[4][1]) && cmp (ib[2][3], ib[3][2]) && cmp (ib[3][3], ib[4][2]);
}
inline bool test11 () {
if (!irt (ib[4])) return false;
return cmp (ib[1][1] + ib[4][1], sl) && cmp (ib[4][2], sl) && cmp (ib[2][1] + ib[3][1], sl) && cmp (ib[1][3], ib[2][3]) && cmp (ib[2][2], ib[3][2]) && cmp (ib[3][3], ib[4][3]);
}
inline bool test12 () {
if (!irt (ib[4])) return false;
return cmp (ib[1][1] + ib[2][1], sl) && cmp (ib[4][2], sl) && cmp (ib[3][1] + ib[4][1], sl) && cmp (ib[1][3], ib[2][2]) && cmp (ib[2][3], ib[3][3]) && cmp (ib[3][2], ib[4][3]);
}
inline bool test13 () {
if (!irt (ib[4])) return false;//no xl
return cmp (ib[1][1] + ib[2][2], sl) && cmp (ib[4][1], sl) && cmp (ib[4][2], sl) && cmp (ib[2][1] + ib[3][1], ib[1][3]) && cmp (ib[2][3], ib[3][2]) && cmp (ib[3][3], ib[4][3]);
}
inline bool test14 () {
return cmp (ib[1][1] + ib[2][1], sl) && cmp (ib[3][3], sl) && cmp (ib[4][3], sl) && cmp (ib[1][3], ib[2][2]) && cmp (ib[3][1] + ib[4][2], ib[2][3]) && cmp (ib[3][2], ib[4][1]);
}
inline bool test15 () {
return cmp (ib[1][1] + ib[2][1], sl) && cmp (ib[3][3], sl) && cmp (ib[4][3], sl) && cmp (ib[1][3], ib[4][1]) && cmp (ib[2][3] + ib[3][2], ib[4][2]) && cmp (ib[2][2], ib[3][1]);
}
inline bool test16 () {
if (!irt (ib[4])) return false;//no xl
return cmp (ib[1][1] + ib[2][3], sl) && cmp (ib[4][1], sl) && cmp (ib[4][2], sl) && cmp (ib[1][3], ib[3][3]) && cmp (ib[2][1], ib[3][1]) && cmp (ib[2][2] + ib[3][2], ib[4][3]);
}
//level 2
inline bool test17 () {
return cmp (ib[2][3], sl) && cmp (ib[4][3], sl) && cmp (ib[2][1] + ib[3][1] + ib[4][1], ib[1][3]) && cmp (ib[3][2], ib[2][2]) && cmp (ib[3][3], ib[4][2]);
}
inline bool test18 () {
if (!irt (ib[4])) return false;
return cmp (ib[3][1] + ib[4][1], sl) && cmp (ib[4][2] + ib[2][1], sl) && cmp (ib[1][3], ib[2][3]) && cmp (ib[2][2], ib[3][3]) && cmp (ib[3][2], ib[4][3]);
}
inline bool test19 () {
// if (cmp (ib[3][2], max ({ib[3][1], ib[3][2], ib[3][3]})) && cmp (ib[4][2], max ({ib[4][1], ib[4][2], ib[4][3]}))) return false;
return cmp (ib[2][3], sl) && cmp (ib[3][1] + ib[4][1], sl) && cmp (ib[3][2], ib[4][2]) && cmp (ib[2][1] + ib[4][3], ib[1][3]) && cmp (ib[2][2], ib[3][3]);
}
inline bool test20 () {
return cmp (ib[2][3], sl) && cmp (ib[4][3], sl) && cmp (ib[2][1] + ib[3][2], ib[1][3]) && cmp (ib[3][1] + ib[4][1], ib[2][2]) && cmp (ib[3][3], ib[4][2]);
}
inline bool test21 () {
return cmp (ib[2][3], sl) && cmp (ib[3][3] + ib[4][1], sl) && cmp (ib[1][3], ib[4][3]) && cmp (ib[2][2] + ib[3][1], ib[4][2]) && cmp (ib[2][1], ib[3][2]);
}
inline bool test22 () {
return cmp (ib[2][3], sl) && cmp (ib[3][3], sl) && cmp (ib[2][1], ib[3][1]) && cmp (ib[4][1], ib[2][2]) && cmp (ib[4][2], ib[3][2]) && cmp (ib[4][3], ib[1][3]);
}
bool sol () {
sl = 0; ott (i, 1, 4) {
ott (j, 1, 3) l2[i][j] = read (); sort (l2[i] + 1, l2[i] + 4);
p = 0; ott (j, 1, 3) p += l[i][j] = (ld)sqrtl (l2[i][j]); p /= 2.0;//, printf ("%0.10Lf\n", l[i][j])
s = p; ott (j, 1, 3) s *= p - l[i][j]; sl += (ld)sqrtl (s); id[i] = i;
}
sl = (ld)sqrtl (sl), xl = sl * pow (2, 0.5); //printf ("%.10Lf\n", sl);
do {
ott (i, 1, 4)
ott (j, 1, 3)
ib[i][j] = l[id[i]][j];
do {
do {
do {
do {
if (test1 ()) return true; if (test2 ()) return true;
if (!cmp (ib[1][2], sl) || !irt (ib[1])) continue;
if (test3 ()) return true; if (test4 ()) return true;
if (test5 ()) return true; if (test6 ()) return true;
if (test7 ()) return true; if (test8 ()) return true;
if (test9 ()) return true; if (test10 ()) return true;
if (test11 ()) return true; if (test12 ()) return true;
if (test13 ()) return true; if (test14 ()) return true;
if (test15 ()) return true; if (test16 ()) return true;
if (!cmp (ib[1][1], sl)) continue;
if (test17 ()) return true; if (test18 ()) return true;
if (test19 ()) return true; if (test20 ()) return true;
if (test21 ()) return true; if (test22 ()) return true;
} while (next_permutation (ib[4] + 1, ib[4] + 4));
} while (next_permutation (ib[3] + 1, ib[3] + 4));
} while (next_permutation (ib[2] + 1, ib[2] + 4));
} while (next_permutation (ib[1] + 1, ib[1] + 4));
} while (next_permutation (id + 1, id + 5));
return false;
}
int main () {
T = read (); while (T --) puts (sol () ? "1" : "0");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
input:
3 1 1 2 2 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 5 125 130 125 20 145 45 130 145 145 145 80
output:
1 0 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3636kb
input:
20 1998001 7984010 9982009 1998001 7984010 1994005 7984010 9978013 9982009 9978013 1994005 7984010 9958045 7968034 9962037 7968034 1994005 9962037 9958045 1990013 7968034 1994005 1990013 7968034 7952074 9938097 1986025 7952074 9942085 1990013 7952074 9942085 9938097 1986025 7952074 1990013 7936130 9...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 20 lines
Test #3:
score: 0
Accepted
time: 9ms
memory: 3760kb
input:
20 1148639 3581051 1216206 9999916 7026968 270268 6013463 6013463 6756700 6013463 6013463 6756700 2608850 8630930 9445800 9862940 6448880 6939290 8631650 3682160 5184310 7504700 6652150 1917140 2359505 3170711 2299108 4027811 6760781 2960240 4679918 6106006 3178400 8153446 7975057 5222088 8849500 88...
output:
0 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 0 1 1 1
result:
ok 20 lines
Test #4:
score: 0
Accepted
time: 18ms
memory: 3632kb
input:
20 7300000 8100000 10000000 8100000 7300000 1000000 1000000 7300000 2900000 2900000 10000000 7300000 61728 8950560 9999936 7901184 4012320 4999968 8950560 3950592 4999968 4012320 123456 4999968 4494200 9932182 9932182 8381683 112355 9932182 5505395 9460291 9932182 9999595 4494200 9190639 5994936 671...
output:
1 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0
result:
ok 20 lines
Test #5:
score: -100
Wrong Answer
time: 17ms
memory: 3624kb
input:
20 10000000 5078125 3828125 78125 5000000 5078125 1250000 10000000 6250000 5000000 6250000 1250000 7079600 5663680 1415920 7079600 796455 9999935 5663680 9999935 5752175 5663680 88495 5752175 4410468 1135368 9999972 5676840 4541472 5676840 4541472 5676840 5676840 8078580 742356 6288192 8345560 44707...
output:
1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 0
result:
wrong answer 9th lines differ - expected: '1', found: '0'