QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669311#7719. Drawing Linesucup-team173TL 46ms4000kbC++206.4kb2024-10-23 18:06:462024-10-23 18:06:48

Judging History

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

  • [2024-10-23 18:06:48]
  • 评测
  • 测评结果:TL
  • 用时:46ms
  • 内存:4000kb
  • [2024-10-23 18:06:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int lim = 1e4;
mt19937_64 rng(time(0));
ll get(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}
int valid(int x) {
    return -lim <= x && x <= lim;
}
// #define local114514

double dst(int a1, int b1, int a2, int b2) {
    return sqrt((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2));
}

int A=get(-lim,lim);
int B=get(-lim,lim);
int C=get(-lim,lim);
int D=get(-lim,lim);
double ask(int x1, int y1, int x2, int y2) {
    if(x1==x2&&y1==y2)return 99.9;
#ifdef local114514
    int X1 = 1000, Y1 = 10000;
    int X2 = 9999, Y2 = 10000;
    double d1 = dst(x1, y1, X1, Y1) + dst(x2, y2, X2, Y2);
    double d2 = dst(x1, y1, X2, Y2) + dst(x2, y2, X1, Y1);
    double s = min(d1, d2);
    double res;
    if (s == 0)
        res = 100.;
    else {
        double sim = max(0., (40000 - s) / 40000);
        res = (int)(sim * 1000) / 10.;
    }
    static int cnt = 0;
    // assert(valid(x1)&&valid(x2)&&valid(y1)&&valid(y2));
    cerr << ++cnt << "th qry\n";
    cerr << x1 << " " << y1 << " " << x2 << " " << y2 << " " << res << "\n";
    if(res==100.)cerr<<"holy jesus you made it\n";
#endif
#ifndef local114514
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    double res;
    cin >> res;
    if(res==100.)exit(0);
#endif
    return res;
}
void make_valid(int& x) {
    x = max(x, -lim);
    x = min(x, lim);
}

void solve() {
    // double t=20000;
    // cerr<<ask(99,99,99,99)<<"\n";
    // cerr<<ask(50,99,99,99)<<"\n";
    // cerr<<ask(50,0,-50,0)<<"\n";
    // return;

    int x1 = get(-lim, lim), y1 = get(-lim, lim);
    int x2 = get(-lim, lim), y2 = get(-lim, lim);
    int x[4] = {x1, y1, x2, y2};
    double old = ask(x1, y1, x2, y2);
    // int timer=24000;
    // int move=0;
    // while(timer--){
    //     move^=1;
    //     int range=(int)max(1.,t);
    //     cerr<<range<<" range\n";
    //     int dx=get(-range,range);
    //     int dy=get(-range,range);
    //     if(move){
    //         dx+=x1,make_valid(dx);
    //         dy+=y1,make_valid(dy);
    //         double newans=ask(dx,dy,x2,y2);
    //         cerr<<dx<<" "<<dy<<" "<<x2<<" "<<y2<<" "<<newans<<"\n";
    //         if(newans==100.)return;
    //         double delta=old-newans;
    //         if(exp(-delta/t)>get(1,1e9)/1e9){
    //             old=newans;
    //             x1=dx,y1=dy;
    //         }
    //     }
    //     else{
    //         dx+=x2,make_valid(dx);
    //         dy+=y2,make_valid(dy);
    //         double newans=ask(x1,y1,dx,dy);
    //         cerr<<x1<<" "<<x2<<" "<<dx<<" "<<dy<<" "<<newans<<"\n";
    //         if(newans==100.)return;
    //         double delta=old-newans;
    //         if(exp(-delta/t)>get(1,1e9)/1e9){
    //             old=newans;
    //             x2=dx,y2=dy;
    //         }
    //     }
    //     t*=0.9993;
    // }
    // cerr<<"fuck, GG\n";
    int change = 0;

    while (1) {
        int l = -lim, r = lim;
        int oldx = x[change];

        while (r - l >= 20) {
            int lm = (l + l + r) / 3., rm = (l + r + r) / 3.;
            x[change] = lm;
            double vl = ask(x[0], x[1], x[2], x[3]);
            if (vl == 100.) exit(0);
            x[change] = rm;
            double vr = ask(x[0], x[1], x[2], x[3]);
            if (vr == 100.) exit(0);
            if (vl > vr)
                r = rm;
            else if (vl < vr)
                l = lm;
            else if (get(0, 1e9) > 5e8)
                l = lm;
            else
                r = rm;
        }
        for (int i = l; i <= r; i++) {
            x[change] = i;
            double v = ask(x[0], x[1], x[2], x[3]);
            if (v == 100.) exit(0);
            if (v > old || (v == old && get(0, 1e9) > 5e8)) {
                oldx = i;
                old = v;
            }
        }
        x[change] = oldx;
        // cerr << x[0] << " " << x[1] << " " << x[2] << " " << x[3] << " " << old << " fuck\n";
        if (old == 99.9) break;
        change = (change + 1) % 4;
    }
    // cerr<<"ok lets go\n";
    while (1) {
        vector<int> choose(4);
        iota(choose.begin(), choose.end(), 0);
        shuffle(choose.begin(), choose.end(), rng);
        int t = choose[0], s = choose[1];
        int tmp = x[s];
        double v = ask(x[0], x[1], x[2], x[3]);
        if(v==100.)exit(0);
        // assert(v == 99.9);
        auto checkfor = [&](int xs) {
            int oldt = x[t];
            int olds = x[s];
            x[s] = xs;
            double v = ask(x[0], x[1], x[2], x[3]);
            if (v != 99.9) return 0;
            int l = 1, r = 1;
            while (valid(oldt - l)) {
                x[t] = oldt - l;
                double v = ask(x[0], x[1], x[2], x[3]);
                if (v == 100.) exit(0);
                if (v != 99.9) break;
                l++;
            }
            while (valid(oldt + r)) {
                x[t] = oldt + r;
                double v = ask(x[0], x[1], x[2], x[3]);
                if (v == 100.) exit(0);
                if (v != 99.9) break;
                r++;
            }
            x[t] = oldt;
            x[s] = olds;
            return r + l - 1;
        };
        auto getxs = [&](int delta) {
            int tmp = x[s] + delta;
            make_valid(tmp);
            return checkfor(tmp);
        };
        int mid = getxs(0);
        int o = 1, L, R;
        while (1) {
            L = getxs(-o), R = getxs(o);
            // cout<<mid<<" "<<L<<" "<<R<<"\n";
            // cerr<<"??"<<" "<<o<<"\n";
            if (L == R && L == mid) {
                o++;
                continue;
            }
            break;
        }
        // cerr<<"whatlaksjdfla\n";
        if (mid >= L && mid >= R) {
            if (L > R && L == mid)
                x[s]--, make_valid(x[s]);
            else if (L < R && R == mid)
                x[s]++, make_valid(x[s]);
        } else {
            if (L > mid)
                x[s]--, make_valid(x[s]);
            else if (R > mid)
                x[s]++, make_valid(x[s]);
            // else
            //     assert(0);
        }
        // cerr << x[0] << " " << x[1] << " " << x[2] << " " << x[3] <<  " fuck\n";
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 17ms
memory: 3780kb

input:

64.5
62.1
61.9
57.8
65.0
63.3
65.3
65.2
64.7
64.8
65.3
65.3
65.2
65.2
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.3
65.8
65.8
60.3
71.3
67.7
73.1
72.6
70.7
...

output:

1499 -3519 8400 6068
-3333 -3519 8400 6068
3333 -3519 8400 6068
-5555 -3519 8400 6068
-1111 -3519 8400 6068
-2592 -3519 8400 6068
370 -3519 8400 6068
-617 -3519 8400 6068
1358 -3519 8400 6068
-1275 -3519 8400 6068
41 -3519 8400 6068
-397 -3519 8400 6068
480 -3519 8400 6068
-690 -3519 8400 6068
-105 ...

result:

ok 6008 queries

Test #2:

score: 0
Accepted
time: 15ms
memory: 3864kb

input:

59.8
50.9
58.1
59.6
55.8
57.5
59.3
59.9
57.8
59.5
59.6
59.8
59.1
59.8
59.7
59.8
59.9
59.9
59.8
59.8
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.9
59.4
42.7
63.1
53.8
64.0
61.2
63.4
62.9
...

output:

1499 -3519 8400 6068
-3333 -3519 8400 6068
3333 -3519 8400 6068
1111 -3519 8400 6068
5555 -3519 8400 6068
-370 -3519 8400 6068
2592 -3519 8400 6068
1605 -3519 8400 6068
3580 -3519 8400 6068
946 -3519 8400 6068
2263 -3519 8400 6068
1824 -3519 8400 6068
2702 -3519 8400 6068
1531 -3519 8400 6068
2116 -...

result:

ok 18468 queries

Test #3:

score: 0
Accepted
time: 46ms
memory: 4000kb

input:

53.0
51.2
54.3
55.6
52.3
55.0
55.0
54.1
55.5
55.2
55.6
55.6
55.5
55.5
55.6
55.6
55.6
55.6
55.5
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
55.6
60.3
57.6
60.7
65.9
62.2
65.0
67.1
62.6
...

output:

7873 4162 -5116 -6988
-3333 4162 -5116 -6988
3333 4162 -5116 -6988
1111 4162 -5116 -6988
5555 4162 -5116 -6988
-370 4162 -5116 -6988
2592 4162 -5116 -6988
-1358 4162 -5116 -6988
617 4162 -5116 -6988
-41 4162 -5116 -6988
1275 4162 -5116 -6988
836 4162 -5116 -6988
1714 4162 -5116 -6988
544 4162 -5116 ...

result:

ok 21951 queries

Test #4:

score: 0
Accepted
time: 25ms
memory: 3780kb

input:

50.1
63.4
59.9
59.7
65.0
64.3
64.4
65.0
63.2
65.0
64.6
64.9
65.0
65.0
64.9
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
65.0
47.4
62.9
57.4
68.5
64.8
72.1
69.7
73.5
...

output:

7873 4162 -5116 -6988
-3333 4162 -5116 -6988
3333 4162 -5116 -6988
-5555 4162 -5116 -6988
-1111 4162 -5116 -6988
-2592 4162 -5116 -6988
370 4162 -5116 -6988
-617 4162 -5116 -6988
1358 4162 -5116 -6988
-1275 4162 -5116 -6988
41 4162 -5116 -6988
-1714 4162 -5116 -6988
-836 4162 -5116 -6988
-1129 4162 ...

result:

ok 16138 queries

Test #5:

score: -100
Time Limit Exceeded

input:

75.3
69.9
75.4
80.1
69.9
77.3
77.2
74.8
79.5
78.0
80.0
79.9
79.2
79.4
80.1
80.0
80.0
80.1
79.8
80.1
80.0
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
80.1
66.2
56.6
71.4
65.2
75.1
67.7
77.6
72.7
79.2
...

output:

3347 -9771 -2903 402
-3333 -9771 -2903 402
3333 -9771 -2903 402
1111 -9771 -2903 402
5555 -9771 -2903 402
-370 -9771 -2903 402
2592 -9771 -2903 402
-1358 -9771 -2903 402
617 -9771 -2903 402
-41 -9771 -2903 402
1275 -9771 -2903 402
836 -9771 -2903 402
1714 -9771 -2903 402
544 -9771 -2903 402
1129 -97...

result: