跳转至

Codeforces Round 1012 (Div. 2)

2025-03-23

比赛链接: https://codeforces.com/contest/2090

这次状态有点差了,赛时只写出了AB。至少C应该不算很难的。。

好好看看吧。

A

没啥好说的,但是我没注意输入顺序和人物的顺序。。WA了一发,麻了。

void ChatGptDeepSeek()
{
    int a, x, y;
    cin >> x >> y >> a;
    a++;
    a %= (x + y);
    if (a == 0)
    {
        cout << "YES\n";
    }
    else if (a <= x)
    {
        cout << "NO\n";
    }
    else
    {
        cout << "YES\n";
    }
}

B

如果一个格子有数字,那么它的左边或者它的上面,一定需要至少有一边是全有数字的。

void ChatGptDeepSeek()
{
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 1; i < n; i++)
        for (int j = 1; j < m; j++)
        {
            if (s[i][j] != '0')
            {
                int ok = 0, cnt = 0;
                for (int k = 0; k < i; k++)
                {
                    if (s[k][j] != '0')
                        cnt++;
                }
                ok |= (cnt == i);
                cnt = 0;
                for (int k = 0; k < j; k++)
                {
                    if (s[i][k] != '0')
                        cnt++;
                }
                ok |= (cnt == j);
                if (!ok)
                {
                    cout << "NO\n";
                    return;
                }
            }
        }
    cout << "YES\n";
}

C

clist 预测的难度是 1600,感觉确实不难的。。甚至可以低一点。。

不是哥们,这怎么随便就能过的啊。

就直接观察到每个点距离是多少,然后拿优先队列模拟一下。

这分掉得好亏啊。这就是不耐心写题想题的下场。

struct node
{
    int dis, x, y;
    friend bool operator<(const node a, const node b)
    {
        if (a.dis == b.dis)
        {
            if (a.x == b.x)
                return a.y < b.y;
            return a.x < b.x;
        }
        return a.dis < b.dis;
    };
    friend bool operator>(const node a, const node b)
    {
        if (a.dis == b.dis)
        {
            if (a.x == b.x)
                return a.y > b.y;
            return a.x > b.x;
        }
        return a.dis > b.dis;
    };
};
void ChatGptDeepSeek()
{
    int n;
    cin >> n;

    priority_queue<node, vector<node>, greater<>> q1; // 无人的
    priority_queue<node, vector<node>, greater<>> q2; // 有人的

    int m = 2 * sqrt(n);
    for (int i = 0; i <= m; i++)
        for (int j = 0; j <= m; j++)
        {
            q1.push({3 * i + 3 * j + 2, 3 * i + 1, 3 * j + 1});
        }
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        // cerr << q1.top().dis << " " << q1.top().x << " " << q1.top().y << '\n';
        // if (q2.size())
        //     cerr << "q2 " << q2.top().dis << " " << q2.top().x << " " << q2.top().y << '\n';

        if (q2.empty() || q2.top() > q1.top() || t == 0)
        {
            auto [dis, x, y] = q1.top();
            q1.pop();
            cout << x << " " << y << '\n';
            q2.push({dis + 1, x + 1, y});
            q2.push({dis + 1, x, y + 1});
            q2.push({dis + 4, x + 1, y + 1});
        }
        else
        {
            cout << q2.top().x << " " << q2.top().y << '\n';
            q2.pop();
        }
    }
    /*
    3x+2,3y+2 需要多走两步
    其余的步数全是横坐标+纵坐标的
    */
}

D

大概1700,应该能想出来的。。明天再看看吧。

不是,怎么能这么智慧?怎么想出来的?

有种思路是,找一个在中间的质数 \(p\) ,然后构造 \([p,p-1,p+1,p-2,p+2,...]\) 这种。。。由于质数是比较密集的,所以在中间其实很快就能找到。

而且由于是向上取整所以 \(\frac{2p-1}{2}, \frac{4p-3}{4}\) 这种其实也是质数。。。太牛。

形不成形,意不在意,再回去练练吧。

constexpr int N = 1e5;
vector<int> minp(N + 1);

void ChatGptDeepSeek()
{
    int n;
    cin >> n;
    vector<int> ans;
    int mid = n / 2;
    for (int i = 0; i < mid; i++)
    {
        if (minp[mid - i] == mid - i)
        {
            mid -= i;
            break;
        }
        if (minp[mid + i] == mid + i)
        {
            mid += i;
            break;
        }
    }
    cout << mid << " ";
    int l = mid - 1, r = mid + 1;
    while (l >= 1 || r <= n)
    {
        if (l >= 1)
        {
            cout << l << ' ';
            l--;
        }
        if (r <= n)
        {
            cout << r << " ";
            r++;
        }
    }
    cout<<'\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    for (int i = 2; i <= N; i++)
    {
        if (minp[i])
            continue;
        minp[i] = i;
        if (1LL * i * i > N)
            continue;
        for (int j = i * i; j <= N; j += i)
            minp[j] = i;
    }
    int T = 1;
    cin >> T;
    while (T--)
        ChatGptDeepSeek();
    return 0;
}