QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#513278 | #9168. Square Locator | ucup-team956# | WA | 0ms | 3608kb | C++20 | 2.1kb | 2024-08-10 17:24:10 | 2024-08-10 17:24:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long
int read() {int x;cin>>x;return x;}
struct point {
int x, y;
point operator-(const point& oth)const{return (point){x-oth.x,y-oth.y};}
point operator+(const point& oth)const{return (point){x+oth.x,y+oth.y};}
friend int dis(const point& A){return A.x * A.x + A.y * A.y;}
};
int cal(int x) {
int val = max(0ll, (int)sqrt(x - 1) - 2ll);
while((val + 1) * (val + 1) <= x) {
val += 1;
}
return val;
}
void solve() {
int OA = read(), OB = read(), OC = read(), OD = read();
point a, b, c, d;
a = {0, cal(OA)};
auto print = [&]() {
cout << a.y << " " << b.x << " " << b.y << " " << c.x << " " << c.y << " " << d.x << " " << d.y << "\n";
return;
};
auto check = [&]() {
point ab = (b - a);
point ad = {-ab.y, ab.x};
d = a + ad;
c = a + ab + ad;
if(dis(a) == OA && dis(b) == OB && dis(c) == OC && dis(d) == OD) {
return 1;
}
return 0;
};
int limit = cal(OB) * 7 / 10;
int res1 = -1;
for(int i = cal(OB); i >= limit; i--) {
int res = OB - i * i;
if(res1 == -1) res1 = cal(res);
if((res1) * (res1) > res) res1 -= 1;
if(res1 * res1 == res) {
b = {i, res1};
if(check()) {
print();
return;
}
b = {res1, i};
if(check()) {
print();
return;
}
b = {-i, res1};
if(check()) {
print();
return;
}
b = {-res1, i};
if(check()) {
print();
return;
}
}
}
// while(1);
}
signed main() {
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
#else
//freopen("a.in", "r", stdin);
#endif
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
36 5 10 41
output:
6 -2 1 3 -1 5 4
result:
ok Answer is correct
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
1 1 1 1
output:
result:
wrong output format Unexpected end of file - int64 expected