QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#669219#7719. Drawing Linesucup-team173#RE 9ms4004kbC++206.4kb2024-10-23 17:44:312024-10-23 17:44:33

Judging History

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

  • [2024-10-23 17:44:33]
  • 评测
  • 测评结果:RE
  • 用时:9ms
  • 内存:4004kb
  • [2024-10-23 17:44:31]
  • 提交

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) {
#ifdef local114514
    int X1 = A, Y1 = B;
    int X2 = C, Y2 = D;
    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]);
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 4004kb

input:

68.8
72.2
72.3
76.2
67.3
76.7
73.8
75.8
76.6
76.8
76.0
76.6
76.7
76.8
76.6
76.8
76.8
76.8
76.7
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
76.8
73.7
73.7
79.2
68.1
81.0
75.5
78.6
80.5
...

output:

-4896 -2088 -1977 -6904
-3333 -2088 -1977 -6904
3333 -2088 -1977 -6904
1111 -2088 -1977 -6904
5555 -2088 -1977 -6904
-370 -2088 -1977 -6904
2592 -2088 -1977 -6904
-1358 -2088 -1977 -6904
617 -2088 -1977 -6904
-41 -2088 -1977 -6904
1275 -2088 -1977 -6904
-480 -2088 -1977 -6904
397 -2088 -1977 -6904
1...

result:

ok 7231 queries

Test #2:

score: 0
Accepted
time: 9ms
memory: 3712kb

input:

56.2
68.6
80.8
78.2
76.2
74.7
80.9
79.3
80.5
81.1
79.2
80.8
80.8
81.0
80.3
81.1
80.9
81.0
81.1
81.1
81.0
81.1
81.1
81.1
81.0
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
81.1
77.4
61.5
79.7
72.3
82.7
78.8
81.1
80.2
...

output:

-8662 -8033 7897 -2629
-3333 -8033 7897 -2629
3333 -8033 7897 -2629
1111 -8033 7897 -2629
5555 -8033 7897 -2629
-370 -8033 7897 -2629
2592 -8033 7897 -2629
1605 -8033 7897 -2629
3580 -8033 7897 -2629
2921 -8033 7897 -2629
4238 -8033 7897 -2629
2482 -8033 7897 -2629
3360 -8033 7897 -2629
3067 -8033 7...

result:

ok 7926 queries

Test #3:

score: 0
Accepted
time: 9ms
memory: 3944kb

input:

61.6
70.6
72.8
73.6
73.9
72.1
75.9
74.7
76.3
76.2
75.9
75.8
76.3
76.2
76.3
76.3
76.2
76.3
76.3
76.3
76.3
76.3
76.2
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.3
76.2
72.3
81.5
74.8
78.7
78.1
76.3
81.1
79.6
...

output:

-8662 -8033 7897 -2629
-3333 -8033 7897 -2629
3333 -8033 7897 -2629
1111 -8033 7897 -2629
5555 -8033 7897 -2629
4074 -8033 7897 -2629
7037 -8033 7897 -2629
6049 -8033 7897 -2629
8024 -8033 7897 -2629
7366 -8033 7897 -2629
8683 -8033 7897 -2629
6927 -8033 7897 -2629
7805 -8033 7897 -2629
7512 -8033 7...

result:

ok 10893 queries

Test #4:

score: -100
Runtime Error

input:

47.0
51.0
52.6
51.0
52.5
52.8
51.1
52.4
52.7
52.8
52.4
52.8
52.7
52.7
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
52.8
64.3
72.9
69.1
75.8
74.0
76.7
76.2
76.9
...

output:

-8662 -8033 7897 -2629
-3333 -8033 7897 -2629
3333 -8033 7897 -2629
1111 -8033 7897 -2629
5555 -8033 7897 -2629
4074 -8033 7897 -2629
7037 -8033 7897 -2629
3086 -8033 7897 -2629
5061 -8033 7897 -2629
4403 -8033 7897 -2629
5720 -8033 7897 -2629
3964 -8033 7897 -2629
4842 -8033 7897 -2629
3671 -8033 7...

result: