QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589089 | #6812. Draw a triangle | Sunlight9# | WA | 27ms | 3864kb | C++20 | 1.3kb | 2024-09-25 16:09:47 | 2024-09-25 16:09:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lll = __int128;
ll dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
ll dy[] = {0, 0, 1, -1 ,1, 1, -1, -1};
void solve() {
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
vector<array<lll, 3> > a;
for (int i = 0; i < 8; ++i) {
ll x = x1 + dx[i];
ll y = y1 + dy[i];
ll X1 = x1 - x, Y1 = y1 - y;
ll X2 = x2 - x, Y2 = y2 - y;
lll S = X1 * Y2 - X2 * Y1;
if (S < 0) S = -S;
if (S) {
a.push_back({S, x, y});
}
}
for (int i = 0; i < 8; ++i) {
ll x = x2 + dx[i];
ll y = y2 + dy[i];
ll X1 = x1 - x, Y1 = y1 - y;
ll X2 = x2 - x, Y2 = y2 - y;
lll S = X1 * Y2 - X2 * Y1;
if (S < 0) S = -S;
if (S) {
a.push_back({S, x, y});
}
}
lll minn = a[0][0];
ll ansx = a[0][1], ansy = a[0][2];
for (int i = 1; i < ssize(a); ++i) {
if (a[i][0] < minn) {
minn = a[i][0];
ansx = a[i][1];
ansy = a[i][2];
}
}
cout << ansx << " " << ansy << "\n";
}
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int _;
cin >> _;
while (_--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
input:
3 1 0 1 4 0 1 0 9 0 0 2 2
output:
2 0 1 1 1 0
result:
ok T=3 (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 27ms
memory: 3864kb
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:
66620474 -33485015 43307887 98029244 -88895229 -3180781 -90319744 20018596 -56783256 84789687 -81798037 90629148 98942946 -939145 -42532150 -57203474 53500208 -30665604 27115055 46989135 -2657411 26865464 40614183 17923421 -47649903 96037712 92954296 -64534917 86508866 -51415165 -82017699 17392575 7...
result:
wrong answer wa on query #4 (test case 4)