QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751519#8779. Square of Trianglescyj888WA 6ms3576kbC++117.4kb2024-11-15 19:14:322024-11-15 19:14:37

Judging History

你现在查看的是最新测评结果

  • [2024-11-15 19:14:37]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3576kb
  • [2024-11-15 19:14:32]
  • 提交

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 db eps = 1e-10;
int T; int l2[5][4], id[5];
db p, s;
db ib[5][4];
db sl, xl; db l[5][4];
inline bool cmp (const db &a1, const db &a2) {
	return fabs (a1 - a2) <= eps;
}
inline bool irt (db* 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]);//sl * pow (2,0.5)
}
//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][1], ib[2][2]) && cmp (ib[3][2], 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 () {
    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] = (db)sqrt (l2[i][j]); p /= 2.0;
		s = p; ott (j, 1, 3) s *= p - l[i][j]; sl += (db)sqrt (s); id[i] = i;
	}
	sl = (db)sqrt (sl), xl = sl * pow (2, 0.5); 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: 0ms
memory: 3576kb

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: -100
Wrong Answer
time: 6ms
memory: 3508kb

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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

wrong answer 1st lines differ - expected: '1', found: '0'