QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754269 | #6812. Draw a triangle | lonelywolf# | WA | 18ms | 3712kb | C++20 | 846b | 2024-11-16 14:37:16 | 2024-11-16 14:37:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct Point {
int x, y;
};
Point operator-(Point a, Point b) {
return {a.x - b.x, a.y - b.y};
}
int cross(Point a, Point b) {
return a.x * b.y - a.y * b.x;
}
int area(Point a, Point b, Point c) {
return abs(cross(b - a, c - a));
}
void solve() {
Point a, b;
cin >> a.x >> a.y >> b.x >> b.y;
int mn = 1e18;
Point ans;
for (int x = a.x - 1; x <= a.x + 1; x++) {
for (int y = a.y - 1; y <= a.y + 1; y++) {
int s = area(a, b, {x, y});
if (s != 0 && s < mn) {
mn = s;
ans = {x, y};
}
}
}
cout << ans.x << " " << ans.y << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
3 1 0 1 4 0 1 0 9 0 0 2 2
output:
0 -1 -1 0 -1 0
result:
ok T=3 (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 18ms
memory: 3672kb
input:
50000 66620473 -33485015 66620223 -33485265 43307886 98029243 43307636 98028994 -88895230 -3180782 -88895480 -3181030 -90319745 20018595 -90319995 20018348 -56783257 84789686 -56783507 84789440 -81798038 90629147 -81798288 90628902 98942945 -939146 98942695 -939390 -42532151 -57203475 -42532401 -572...
output:
66620472 -33485015 43307885 98029242 -88895231 -3180783 -90319746 20018594 -56783258 84789685 -81798039 90629146 98942944 -939147 -42532152 -57203476 53500206 -30665606 27115053 46989133 -2657413 26865462 40614181 17923419 -47649905 96037710 92954294 -64534919 86508864 -51415167 -82017701 17392573 7...
result:
wrong answer wa on query #4 (test case 4)