1 条题解

  • 4
    @ 2024-10-5 17:25:28

    直接分 3636 种情况大力分类讨论即可。当然了,直接这么写的话,代码会很长;因此,我们可以以 x=4.5x=4.5y=4.5y=4.5 为分界线,将 3636 种情况等分成 44 份,这样就只需要对 99 种情况分类讨论了。

    #include <bits/stdc++.h>
    using namespace std;
    int dx, dy, res;
    bool first()
    {
        cout << "3 3" << endl;
        cin >> res;
        if (res == 2) return true;
        if (res == 1)
        {
            dx = 3;
            dy = 3;
            return false;
        }
        cout << "3 6" << endl;
        cin >> res;
        if (res == 2) return true;
        if (res == 1)
        {
            dx = 3;
            dy = 6;
            return false;
        }
        cout << "6 3" << endl;
        cin >> res;
        if (res == 2) return true;
        if (res == 1)
        {
            dx = 6;
            dy = 3;
            return false;
        }
        dx = 6;
        dy = 6;
        return false;
    }
    bool go()
    {
        if (first()) return true;
        cout << dx + 1 << ' ' << dy + 1 << endl;
        cin >> res;
        if (res == 2) return true;
        if (res == 1)
        {
            cout << dx + 1 << ' ' << dy - 1 << endl;
            cin >> res;
            if (res == 0)
            {
                cout << dx << ' ' << dy + 1 << endl;
                cin >> res;
                return true;
            }
            cout << dx << ' ' << dy << endl;
            cin >> res;
            if (res == 2) return true;
            cout << dx + 1 << ' ' << dy << endl;
            cin >> res;
            return true;
        }
        else
        {
            cout << dx << ' ' << dy - 2 << endl;
            cin >> res;
            if (res == 0)
            {
                cout << dx - 1 << ' ' << dy << endl;
                cin >> res;
                if (res == 2) return true;
                cout << dx - 1 << ' ' << dy + 1 << endl;
                cin >> res;
                return true;
            }
            cout << dx + 1 << ' ' << dy - 1 << endl;
            cin >> res;
            if (res == 2) return true;
            if (res == 0)
            {
                cout << dx - 1 << ' ' << dy - 1 << endl;
                cin >> res;
                return true;
            }
            cout << dx << ' ' << dy - 1 << endl;
            cin >> res;
            return true;
        }
    }
    int main()
    {
        int T;
        cin >> T;
        while (T--) go();
        return 0;
    }
    
    • 1

    信息

    ID
    28
    时间
    1000ms
    内存
    512MiB
    难度
    4
    标签
    递交数
    5
    已通过
    3
    上传者