QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114847 | #5320. Triangles and Quadrangle | PetroTarnavskyi# | WA | 2ms | 3456kb | C++17 | 3.1kb | 2023-06-23 18:33:41 | 2023-06-23 18:33:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const double EPS = 1e-6;
struct point
{
int x, y;
point (): x(0), y(0) {}
point (int _x, int _y): x(_x), y(_y) {}
int getl(point p)
{
int dx = x - p.x;
int dy = y - p.y;
return dx * dx + dy * dy;
}
point operator -(const point& p) const
{
return point(x - p.x, y - p.y);
}
};
vector<int> len(vector<point> t)
{
vector<int> res;
res.PB(t[0].getl(t[1]));
res.PB(t[0].getl(t[2]));
res.PB(t[2].getl(t[1]));
sort(ALL(res));
return res;
}
vector<point> t1, t2, sq;
int area(point a, point b, point c)
{
a = a - c;
b = b - c;
return a.x * b.y - a.y * b.x;
}
bool check()
{
VI d1 = len(t1);
VI d2 = len(t2);
FOR (t, 0, 2)
{
VI ds1 = len({sq[t], sq[t + 1], sq[t + 2]});
VI ds2 = len({sq[t + 2], sq[(t + 3) % 4], sq[(t + 4) % 4]});
if (d1 == ds1 && d2 == ds2)
return 1;
if (d1 == ds2 && d2 == ds1)
return 1;
}
return 0;
}
bool check2()
{
vector<point> t3;
FOR (i, 0, 4)
{
if (abs(area(sq[i], sq[(i + 1) % 4], sq[(i + 2) % 4])) > 0)
t3.PB(sq[(i + 1) % 4]);
}
if (SZ(t3) != 3) return 0;
int a1 = abs(area(t1[0], t1[1], t1[2]));
int a2 = abs(area(t2[0], t2[1], t2[2]));
int a3 = abs(area(t3[0], t3[1], t3[2]));
if (a3 != a1 + a2) return false;
VI d1 = len(t1);
VI d2 = len(t2);
VI d3 = len(t3);
VI idx1(3), idx2(3), idx3(3);
iota(ALL(idx1), 0);
iota(ALL(idx2), 0);
iota(ALL(idx3), 0);
bool ok = false;
do
{
do
{
do
{
if (d1[idx1[0]] != d2[idx2[0]])
continue;
if (d1[idx1[1]] != d3[idx3[0]])
continue;
if (d2[idx2[1]] != d3[idx3[1]])
continue;
double l1 = sqrt(d1[idx1[2]]);
double l2 = sqrt(d2[idx2[2]]);
double l3 = sqrt(d3[idx3[2]]);
LL a = d1[idx1[1]];
LL b = d2[idx2[1]];
LL x = d1[idx1[0]];
LL d = d1[idx1[2]];
LL c = d2[idx2[2]];
double L1 = (a - x - d) / l1;
double L2 = (x + c - b) / l2;
if (abs(l3 - l2 - l1) < EPS && abs(L1 - L2) < EPS)
ok = true;
} while (next_permutation(ALL(idx3)));
sort(ALL(idx3));
} while (next_permutation(ALL(idx2)));
sort(ALL(idx2));
} while (next_permutation(ALL(idx1)));
return ok;
}
void solve()
{
t1.resize(3);
t2.resize(3);
sq.resize(4);
FOR (i, 0, 3) cin >> t1[i].x >> t1[i].y;
FOR (i, 0, 3) cin >> t2[i].x >> t2[i].y;
FOR (i, 0, 4) cin >> sq[i].x >> sq[i].y;
if (check() || check2())
{
cout << "Yes\n";
}
else
{
cout << "No\n";
}
t1.clear();
t2.clear();
sq.clear();
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
FOR (tt, 0, t)
{
cout << "Case #" << tt + 1 << ": ";
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3456kb
input:
500 -1363 3930 -1342 3930 -1355 3934 2730 -560 2709 -560 2722 -556 -2484 -2677 -2476 -2673 -2484 -2669 -2497 -2673 -1810 2709 -1831 2709 -1818 2705 -4735 -3180 -4743 -3184 -4722 -3184 4271 -1177 4267 -1169 4263 -1177 4267 -1190 3800 -3033 3821 -3033 3808 -3029 -3242 224 -3234 228 -3255 228 -3847 170...
output:
Case #1: Yes Case #2: Yes Case #3: No Case #4: No Case #5: Yes Case #6: Yes Case #7: Yes Case #8: Yes Case #9: Yes Case #10: Yes Case #11: Yes Case #12: Yes Case #13: Yes Case #14: Yes Case #15: Yes Case #16: Yes Case #17: Yes Case #18: Yes Case #19: Yes Case #20: Yes Case #21: Yes Case #22: Yes Cas...
result:
wrong answer 432nd lines differ - expected: 'Case #432: Yes', found: 'Case #432: No'