結果

問題 No.2779 Don't make Pair
ユーザー NAMIDAIRONAMIDAIRO
提出日時 2024-06-07 21:57:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 1,213 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 121,756 KB
実行使用メモリ 7,808 KB
最終ジャッジ日時 2024-06-07 21:58:04
合計ジャッジ時間 3,311 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 8 ms
6,940 KB
testcase_10 AC 33 ms
6,944 KB
testcase_11 AC 11 ms
6,940 KB
testcase_12 AC 36 ms
6,944 KB
testcase_13 AC 39 ms
6,940 KB
testcase_14 AC 35 ms
6,940 KB
testcase_15 AC 60 ms
6,940 KB
testcase_16 AC 60 ms
6,940 KB
testcase_17 AC 57 ms
6,944 KB
testcase_18 AC 49 ms
6,944 KB
testcase_19 AC 53 ms
6,944 KB
testcase_20 AC 26 ms
6,940 KB
testcase_21 AC 71 ms
6,944 KB
testcase_22 AC 54 ms
6,940 KB
testcase_23 AC 120 ms
7,808 KB
testcase_24 AC 61 ms
6,940 KB
testcase_25 AC 62 ms
6,940 KB
testcase_26 AC 85 ms
6,944 KB
testcase_27 AC 81 ms
6,940 KB
testcase_28 AC 77 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T>
using vi = vector<T>;

template<class T>
using vii = vector<vi<T>>;

template<class T>
using viii = vector<vii<T>>;

template<class T>
using viiii = vector<viii<T>>;

using P = pair<ll, int>;

void chmin(ll & x, ll y) { x = min(x, y); }

void chmax(ll& x, ll y) { x = max(x, y); }

int main()
{
    int n;
    cin >> n;
    vi<int> a(n);
    rep(i, n) cin >> a[i];

    int l = 0, r = n;
    set<int> st;
    rep(i, n) {
        if (st.count(a[i])) break;
        st.insert(a[i]);
        l = i + 1;
    }

    st.clear();
    for (int i = n - 1; i >= 0; i--) {
        if (st.count(a[i])) break;
        st.insert(a[i]);
        r = i;
    }

    r = max(r, 1);
    l = min(l, n - 1);
    int ans = l - r + 1;
    if (ans <= 0) {
        cout << 0 << endl;
        cout << endl;
        return 0;
    }
    cout << ans << endl;
    for (int i = r; i <= l; i++) cout << i << " \n"[i == l];
    return 0;
}

0