题解归档 - cf2219B1

题解归档 - cf2219B1

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

思路

cf2219B1 - Unique Values (Easy version)

Pattern

The original problem is interactive, but the hacked format provides the whole
array. Therefore no query simulation is needed.

Exactly one value appears three times and all other values appear twice. Store
the positions for every value and print the three positions of the value whose
position list has length 3.

Checks

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

代码

来源:problems/cf2219B1/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
文章标题:题解归档 - cf2219B1
文章链接:https://www.fangshaonian.cn/archives/206/
最后编辑:2026 年 6 月 28 日 19:04 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
(*) 5 + 7 =
快来做第一个评论的人吧~