QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#519068#9168. Square Locatorclear_teaWA 0ms3700kbC++202.0kb2024-08-14 15:54:592024-08-14 15:55:00

Judging History

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

  • [2024-08-14 15:55:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3700kb
  • [2024-08-14 15:54:59]
  • 提交

answer

#include <bits/stdc++.h>

#define int __int128
using ll = long long;
using namespace std;

mt19937_64 rnd(time(0));
//整数开方, 利用二分去查找
int sq(int x) {
    int l = 0, r = 1e18 + 10;
    while (r > 1 + l) {
        int mid = (r + l) >> 1;
        if (mid * mid <= x) l = mid;
        else r = mid;
    }
    return l;
}

struct point {
    int x, y;

//    point(int x, int y): x(x), y(y){}

    point clk90(point B) {
        int dx = B.x - x;
        int dy = B.y - y;
        return {x + dy, y - dx};
    }

    point anti_clk90(point B) {
        int dx = B.x - x;
        int dy = B.y - y;
        return {x - dy, y + dx};
    }

    int disSqr(point B) {
        return (B.x - x) * (B.x - x) + (B.y - y) * (B.y - y);
    }

};

int d1, d2, d3, d4;
point A, B, C, D;
void print(){
    cout << (ll)A.y << " " << (ll)B.x << " " << (ll)B.y << " ";
    cout << (ll)C.x << " " << (ll)C.y << " " << (ll)D.x << " " << (ll)D.y;
    exit(0);
}

void check(int L) {
    B.y = (d1 + d2 - L) / 2 / A.y;
    B.x = sq(d2 - B.y * B.y);
    C = B.clk90(A);
    D = C.clk90(B);
    if(C.disSqr({0,0}) == d3 && D.disSqr({0, 0}) == d4) print();
    else{
        B.x = -B.x;
        C = B.clk90(A);
        D = C.clk90(B);
        if(C.disSqr({0,0}) == d3 && D.disSqr({0, 0}) == d4) print();
    }
}

void solve() {
    ll dd1, dd2, dd3, dd4;
    cin >> dd1 >> dd2 >> dd3 >> dd4;
    d1 = dd1, d2 = dd2, d3 = dd3, d4 = dd4;
    A = {0, sq(dd1)};
    int a = 2, b = -2 * (d2 + d4), c = (2 * d1 * d1 + d2 * d2 + d4 * d4 - 2 * d1 * d2 - 2 * d1 * d4);
    int det = sq(b * b - 4 * a * c);
    int x1 = (det - b) / 2 / a;
    int x2 = (-1 * det - b) / 2 / a;
    check(x1);
    check(x2);
    cout << "no ans";
}

signed main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll Tcase = 1;
//    cin >> Tcase;
    while (Tcase--) {
        solve();
    }
//    ll a = 1e8, b = 1e8 + 1;
//    cout << a * a << " " << 1 << " " << 1 + b*b << " " << a*a + b*b;
    return 0;
}

详细

Test #1:

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

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: 3700kb

input:

1 1 1 1

output:

1 -1 0 0 -1 1 0

result:

ok Answer is correct

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000

output:

no ans

result:

wrong output format Expected integer, but "no" found