結果

問題 No.2779 Don't make Pair
ユーザー haihamabossuhaihamabossu
提出日時 2024-06-07 22:17:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 210,636 KB
実行使用メモリ 16,440 KB
最終ジャッジ日時 2024-06-07 22:17:55
合計ジャッジ時間 4,626 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 10 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 45 ms
8,840 KB
testcase_13 AC 28 ms
7,168 KB
testcase_14 AC 34 ms
7,424 KB
testcase_15 AC 76 ms
11,776 KB
testcase_16 AC 67 ms
11,008 KB
testcase_17 AC 59 ms
10,088 KB
testcase_18 AC 48 ms
9,032 KB
testcase_19 AC 69 ms
11,008 KB
testcase_20 AC 28 ms
7,040 KB
testcase_21 AC 92 ms
13,568 KB
testcase_22 AC 76 ms
12,288 KB
testcase_23 AC 147 ms
16,440 KB
testcase_24 AC 73 ms
11,904 KB
testcase_25 AC 85 ms
12,672 KB
testcase_26 AC 123 ms
14,592 KB
testcase_27 AC 108 ms
14,464 KB
testcase_28 AC 139 ms
14,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve() {
  ll n, cnt = 0;
  cin >> n;
  map<ll, ll> mpl, mpr;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    if (++mpr[a[i]] == 2)
      cnt++;
  }
  vector<ll> ans;
  rep(i, n - 1) {
    if (--mpr[a[i]] == 1)
      cnt--;
    if (++mpl[a[i]] == 2)
      break;
    if (cnt == 0)
      ans.push_back(i + 1);
  }
  cout << ans.size() << '\n';
  rep(i, ans.size()) cout << (i ? " " : "") << ans[i];
  cout << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0