QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#563496 | #9227. Henry the Plumber | arnold518# | WA | 0ms | 3736kb | C++17 | 2.0kb | 2024-09-14 13:05:15 | 2024-09-14 13:05:16 |
Judging History
answer
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
struct frac {
ll u, d;
frac operator+(frac ot) { return { u * ot.d + ot.u * d, d * ot.d }; }
frac operator-(frac ot) { return { u * ot.d - ot.u * d, d * ot.d }; }
frac operator*(frac ot) { return { u * ot.u, d * ot.d }; }
};
struct point {
int x, y;
};
point operator+(point a, point b) { return {a.x + b.x, a.y + b.y}; }
point operator-(point a, point b) { return {a.x - b.x, a.y - b.y}; }
int operator*(point a, point b) { return a.x * b.x + a.y * b.y; }
int operator/(point a, point b) { return a.x * b.y - a.y * b.x; }
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
int TC;
cin >> TC;
while (TC--) {
point S, T; int z[2];
point vecS, vecT;
cin >> S.x >> S.y >> z[0];
cin >> vecS.x >> vecS.y;
cin >> T.x >> T.y >> z[1];
cin >> vecT.x >> vecT.y;
if ((S - T) * vecS == 0 && (S - T) * vecT == 0) {
cout << "2\n";
}
else {
vecS = {-vecS.y, vecS.x};
vecT = {-vecT.y, vecT.x};
if (vecS / vecT == 0) cout << "4\n";
else if (z[0] == z[1] && ((S - T) / vecS == 0 || (S - T) / vecT == 0)) cout << "4\n";
else {
frac k = {((T - S) / vecT), (vecS / vecT)};
if (k.d < 0) k.u *= -1, k.d *= -1;
frac x = frac{S.x, 1} + k * frac{vecS.x, 1};
frac y = frac{S.y, 1} + k * frac{vecS.y, 1};
x = frac{S.x + T.x, 1} - frac{2, 1} * x;
y = frac{S.y + T.y, 1} - frac{2, 1} * y;
// check x * x + y * y <= (S - T) * (S - T);
assert(x.d == y.d);
if (x.u * x.u + y.u * y.u <= (S - T) * (S - T) * x.d * x.d) {
cout << "3\n";
}
else cout << "4\n";
}
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
2 -1 -1 3 1 1 2 2 3 2 2 5 5 1 3 0 7 6 -2 1 -2
output:
4 3
result:
ok 2 number(s): "4 3"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3736kb
input:
100 -13 -5 -7 -19 19 -19 -13 0 -7 15 -20 20 19 -17 18 20 -20 -1 18 -19 -18 15 -14 -19 18 19 -20 6 20 -19 -12 9 1 7 -16 -13 -14 -8 8 -13 -19 16 9 20 -19 19 -18 -11 19 -18 19 20 -8 12 20 -11 -9 18 -19 -18 8 11 -13 12 -18 18 13 8 4 -18 -16 20 17 -19 18 20 -18 -3 20 -19 -17 -20 -5 -18 -19 19 16 15 19 20...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 3 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 4 4 4 4 3 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 3 3 4 3 4 4 4 4 4 4 4 4 4
result:
wrong answer 7th numbers differ - expected: '3', found: '4'