結果

問題 No.2779 Don't make Pair
ユーザー 矢澤式WINTER矢澤式WINTER
提出日時 2024-06-07 22:15:20
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 1,468 bytes
コンパイル時間 3,216 ms
コンパイル使用メモリ 257,056 KB
実行使用メモリ 13,284 KB
最終ジャッジ日時 2024-06-07 22:15:29
合計ジャッジ時間 5,304 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 11 ms
6,940 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 53 ms
7,884 KB
testcase_13 AC 59 ms
8,192 KB
testcase_14 AC 46 ms
6,944 KB
testcase_15 AC 94 ms
10,624 KB
testcase_16 AC 105 ms
11,136 KB
testcase_17 AC 65 ms
8,704 KB
testcase_18 AC 48 ms
7,444 KB
testcase_19 AC 76 ms
9,580 KB
testcase_20 AC 33 ms
6,944 KB
testcase_21 AC 127 ms
13,056 KB
testcase_22 AC 128 ms
13,056 KB
testcase_23 AC 135 ms
13,284 KB
testcase_24 AC 131 ms
13,056 KB
testcase_25 AC 129 ms
13,056 KB
testcase_26 AC 152 ms
13,056 KB
testcase_27 AC 130 ms
12,928 KB
testcase_28 AC 129 ms
13,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/*/
#include <atcoder/all>
using namespace atcoder;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//*/
#define rep(i,n) for(ll i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dbgv(x); for(auto now : x) cout << now << " "; cout << endl;
//using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
//*/
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vint;
random_device rnd;
mt19937 rng(rnd());

void solve(){
  int n; cin >> n;
  vint a(n); rep(i,n) cin >> a[i];
  map<int,int> bac,pre;
  int cnt = 0;
  rep(i,n){
    bac[a[i]]++;
    if(bac[a[i]] == 2) cnt++;
  }
  int ok = true;
  vint ans;
  rep(i,n-1){
    bac[a[i]]--;
    pre[a[i]]++;
    if(pre[a[i]] == 2) ok = false;
    if(bac[a[i]] == 1) cnt--;
    if(ok && cnt==0){
      ans.push_back(i+1);
    }
  }
  cout << ans.size() << endl;
  dbgv(ans);
}
 

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1; //cin >> t;
  rep(testcase,t) solve();
}
0