QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#513206 | #9168. Square Locator | ucup-team956# | TL | 0ms | 3676kb | C++20 | 2.1kb | 2024-08-10 17:12:17 | 2024-08-10 17:12:18 |
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;
};
for(int i = cal(OB); i >= cal(OB) * 8 / 10; i--) {
int res = OB - i * i;
int res1 = cal(res);
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: 3624kb
input:
36 5 10 41
output:
6 -2 1 3 -1 5 4
result:
ok Answer is correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 1 1 1
output:
1 0 1 0 1 0 1
result:
ok Answer is correct
Test #3:
score: -100
Time Limit Exceeded
input:
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000