QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#513220#9168. Square Locatorucup-team956#TL 0ms3860kbC++202.1kb2024-08-10 17:14:092024-08-10 17:14:10

Judging History

你现在查看的是最新测评结果

  • [2024-08-10 17:14:10]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3860kb
  • [2024-08-10 17:14:09]
  • 提交

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;
    for(int i = cal(OB); i >= limit; 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: 3608kb

input:

36 5 10 41

output:

6 -1 2 3 1 4 5

result:

ok Answer is correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3860kb

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

output:


result: