题解归档 - cf2219B2

题解归档 - cf2219B2

本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。

思路

cf2219B2 - Unique Values (Hard version)

Pattern

The hard version only changes the original interactive query limit. In hacked
input, the entire array is provided, so B1 and B2 have the same offline
solution.

Store positions for each value and print the three positions of the unique
value whose list length is 3.

Checks

  • python tools/math_reasoning_search.py --problem cf2219B2 -n 5 - required
    precheck done by plan flag.
  • Local sample uses the hacked input format rather than the original transcript.

代码

来源:problems/cf2219B2/solution.cpp

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        vector<vector<int>> pos(n + 1);
        for (int i = 1; i <= 2 * n + 1; i++) {
            int x;
            cin >> x;
            pos[x].push_back(i);
        }
        for (int x = 1; x <= n; x++) {
            if ((int)pos[x].size() == 3) {
                cout << "! " << pos[x][0] << ' ' << pos[x][1] << ' ' << pos[x][2] << '\n';
                break;
            }
        }
    }
    return 0;
}
~  ~  The   End  ~  ~


 赏 
感谢您的支持,我会继续努力哒!
支付宝收款码
tips
文章二维码 分类标签:归档TypechoAutoUpload
文章标题:题解归档 - cf2219B2
文章链接:https://www.fangshaonian.cn/archives/207/
最后编辑:2026 年 6 月 28 日 19:04 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
(*) 6 + 5 =
快来做第一个评论的人吧~