QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#513181#9168. Square Locatorucup-team956#TL 0ms3684kbC++202.0kb2024-08-10 17:09:312024-08-10 17:09:32

Judging History

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

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

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 = sqrt(x - 1) - 3;
    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) * 7 / 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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

36 5 10 41

output:

6 -1 2 3 1 4 5

result:

ok Answer is correct

Test #2:

score: -100
Time Limit Exceeded

input:

1 1 1 1

output:


result: