結果

問題 No.2779 Don't make Pair
ユーザー t98slidert98slider
提出日時 2024-06-07 21:41:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 210,304 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-06-07 21:41:35
合計ジャッジ時間 3,679 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 10 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 22 ms
5,888 KB
testcase_13 AC 22 ms
6,016 KB
testcase_14 AC 26 ms
6,656 KB
testcase_15 AC 37 ms
7,424 KB
testcase_16 AC 36 ms
7,168 KB
testcase_17 AC 42 ms
8,192 KB
testcase_18 AC 36 ms
7,680 KB
testcase_19 AC 33 ms
7,040 KB
testcase_20 AC 17 ms
5,376 KB
testcase_21 AC 41 ms
7,424 KB
testcase_22 AC 25 ms
5,504 KB
testcase_23 AC 86 ms
12,416 KB
testcase_24 AC 32 ms
6,528 KB
testcase_25 AC 34 ms
6,656 KB
testcase_26 AC 48 ms
8,320 KB
testcase_27 AC 50 ms
8,704 KB
testcase_28 AC 44 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    map<int,int> mp, mp2;
    int r = -1;
    for(int i = 0; i < n; i++){
        mp[a[i]]++;
        if(mp[a[i]] == 1) r = i + 1;
        else break;
    }
    int l = n;
    for(int i = n - 1; i >= 0; i--){
        mp2[a[i]]++;
        if(mp2[a[i]] == 1) l = i;
        else break;
    }
    vector<int> ans;
    for(int i = max(1, l); i <= r && i <= n - 1; i++){
        ans.push_back(i);
    }
    cout << ans.size() << '\n' << ans << '\n';
}
0