QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#539695 | #6812. Draw a triangle | ucup-team1329# | WA | 20ms | 3544kb | C++14 | 2.5kb | 2024-08-31 15:26:57 | 2024-08-31 15:26:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const ll mod = 1000000007;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};
void solve()
{
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
ld ans = inf;
ll dx, dy;
for (int i = 0; i < 8; i++)
{
ll x3 = x1 + dir[i][0], y3 = y1 + dir[i][1];
ld a = sqrtl((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
ld b = sqrtl((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
ld c = sqrtl((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
ld p = (a + b + c) / 2.0;
ld s = sqrtl(p * (p - a) * (p - b) * (p - c));
if (s < eps)
continue;
if (s < ans)
{
ans = s;
dx = x3;
dy = y3;
}
}
cout << dx << " " << dy << "\n";
}
int main()
{
IOS int T = 1;
cin >> T;
while (T--)
solve();
return 0;
}
/*
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
x o
o _/_/_/_/ _/ x
x _/ o
o _/_/_/_/ _/ _/_/ _/_/ _/_/_/ _/_/ _/_/_/ _/_/ _/_/_/ _/ _/ _/ x
x _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ o
o _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ x
x _/ _/ _/_/ _/ _/ _/ _/_/_/ _/_/ _/ _/ _/ _/ _/ o
o _/ _/ _/ x
x _/ _/_/ _/ o
o x
xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
3 1 0 1 4 0 1 0 9 0 0 2 2
output:
2 -1 1 2 -1 0
result:
ok T=3 (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 20ms
memory: 3524kb
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 -33485016 43307887 98029244 -88895231 -3180783 -90319744 20018596 -56783258 84789685 -81798039 90629146 98942946 -939145 -42532150 -57203474 53500206 -30665606 27115053 46989133 -2657411 26865464 40614181 17923419 -47649905 96037710 92954296 -64534917 86508864 -51415167 -82017699 17392575 7...
result:
wrong answer wa on query #1 (test case 1)