結果

問題 No.2779 Don't make Pair
コンテスト
ユーザー GOTKAKO
提出日時 2024-06-07 21:40:34
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 679 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,293 ms
コンパイル使用メモリ 218,720 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2026-07-04 20:49:33
合計ジャッジ時間 2,892 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

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

    int N; cin >> N;
    vector<int> A(N);
    for(auto &a : A) cin >> a;

    int L = -1,R = N;
    set<int> S;
    for(int i=0; i<N; i++){
        int a = A.at(i);
        if(S.count(a)) break;
        S.insert(a); L++;
    }
    L = min(N-2,L);
    S.clear();
    for(int i=N-1; i>=0; i--){
        int a = A.at(i);
        R--;
        if(S.count(a)) break;
        S.insert(a);
    }

    vector<int> answer;
    for(int i=R; i<=L; i++) answer.push_back(i+1);
    cout << answer.size() << endl;
    for(auto a : answer) cout << a << " "; cout << endl;
}
0