QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109451#5206. Hot and ColdgigabuffoonWA 0ms3396kbC++205.3kb2023-05-29 02:26:142023-05-29 02:26:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-29 02:26:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3396kb
  • [2023-05-29 02:26:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) int(size(x))
#define rep(a, b, c) for (int a = (b); a < (c); a++)
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

map<string, int> ids;
const int MAX_X = 1'000'000;

int CLOSER = -1;
int FURTHER = -1;
int SAME = -1;

ll ansX, ansY;
ll lastD = -1;

int queries = 0;

// int query(ll x, ll y) {
//     cout << x << " " << y << endl;
//     queries++;

//     if (tie(x, y) == tie(ansX, ansY)) {
//         cout << "found in " << queries << "!" << endl;
//         exit(0);
//     }

//     ll dx = x - ansX, dy = y - ansY;
//     ll dist = dx*dx + dy*dy;

//     int ret;
//     if (lastD == -1) ret = 0;
//     else if (lastD < dist) ret = 1;
//     else if (lastD > dist) ret = 2;
//     else ret = 3;

//     lastD = dist;
//     cout << "said " << ret << "\n";
    
//     if (CLOSER != -1 && FURTHER != -1 && SAME == -1 && ret != CLOSER && ret != FURTHER) {
//         cout << "Found same!" << endl;
//         SAME = ret;
//     }

//     return ret;
// }

int query(int x, int y) {
    cout << x << " " << y << endl;
    string ret;
    cin >> ret;

    if (ret.back() == '!') {
        exit(0);
    }

    int rval;

    if (ids.count(ret)) rval = ids[ret];
    else rval = ids[ret] = sz(ids);

    if (CLOSER != -1 && FURTHER != -1 && SAME == -1 && rval != CLOSER && rval != FURTHER)
        SAME = rval;

    return rval;
}

void solve() {
    query(0, 0);
    int v1 = query(1, 0);
    int far = query(0, 0);
    int v2 = query(0, 1);

    int loX = 0, hiX = MAX_X;
    int loY = 0, hiY = MAX_X;
    int lastX = 0;
    int lastY = 0;

    if (v1 == v2) {
        CLOSER = v1;
        FURTHER = far;
    }
    else {
        query(MAX_X, 0);
        query(0, MAX_X);
        query(MAX_X, MAX_X);
        int v3 = query(MAX_X, MAX_X-1);
        CLOSER = v3;
        FURTHER = (v3 == v1 ? v2 : v1);

        // SAVE QUERIES 
        query(0, 0);
        if (query(1, 0) == CLOSER) loY = hiY = 0;
        else loX = hiX = 0;
    }

    // cout << "CLOSER: " << CLOSER << "\n";
    // cout << "FURTHER: " << FURTHER << "\n";
    // cout << "SAME: " << SAME << "\n";
    // cout.flush();
    ll wantX = loX, wantY = loY;

    bool doY = 0;

    while (loX < hiX || loY < hiY) {
        if (doY || loX == hiX) {
            int next = clamp(loY + hiY - lastY, 0, MAX_X);
            int ret = query(lastX, next);

            // cout << "loY " << loY << " hiY " << hiY << " lastY " << lastY << " next " << next << "\n";

            int cutLo = (lastY + next) / 2;
            int cutHi = (lastY + next + 1) / 2;

            if (ret == SAME) {
                assert((lastY + next) % 2 == 0);
                loY = hiY = (lastY + next) / 2;
            }
            else if (lastY < next) {
                if (ret == CLOSER) loY = max(loY, cutHi);
                else hiY = min(hiY, cutLo);
            }
            else { // next < last
                if (ret == CLOSER) hiY = min(hiY, cutLo);
                else loY = max(loY, cutHi);
            }

            if (ret == FURTHER) {
                if (lastY < next)
                    wantY = loY;
                else
                    wantY = hiY;

                query(wantX, wantY);
                doY = 0;
                lastX = wantX;
                lastY = wantY;
            }
            else {
                lastY = next;
            }

        }    
        else { // do X

            int next = clamp(loX + hiX - lastX, 0, MAX_X);
            int ret = query(next, lastY);

            // cout << "loX " << loX << " hiX " << hiX << " lastX " << lastX << " next " << next << "\n";

            int cutLo = (lastX + next) / 2;
            int cutHi = (lastX + next + 1) / 2;

            if (ret == SAME) {
                assert((lastX + next) % 2 == 0);
                loX = hiX = (lastX + next) / 2;
            }
            else if (lastX < next) {
                if (ret == CLOSER) loX = max(loX, cutHi);
                else hiX = min(hiX, cutLo);
            }
            else { // next < last
                if (ret == CLOSER) hiX = min(hiX, cutLo);
                else loX = max(loX, cutHi);
            }

            if (ret == FURTHER) {
                if (loY < hiY) {
                    doY = 1;
                    lastX = next;
                
                    if (lastX < next)
                        wantX = loX;
                    else
                        wantX = hiX;
                }
                else {              
                    if (lastX < next)
                        wantX = loX;
                    else
                        wantX = hiX;

                    query(wantX, loY);
                    lastX = wantX;
                }
            }
            else {
                wantX = next;
                lastX = next;
            }
        }   
    }

    // cout << "GOT " << loX << " " << loY << endl;
    query(loX, loY);

    // cout << "bruv" << endl;
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
    cin.exceptions(cin.failbit);
 
    // cin >> ansX >> ansY;

    solve(); 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3396kb

input:

Tabilmadi
Daha yakin
Dalej
Daha yakin
Dalej
Dalej
Dalej
Daha yakin
Daha yakin
Daha yakin
Dalej
Daha yakin

output:

0 0
1 0
0 0
0 1
1000000 0
0 1000000
1000000 1000000
1000000 999999
0 0
1 0
0 1000000
0 500000

result:

wrong answer format  Unexpected end of file - int32 expected