結果

問題 No.2779 Don't make Pair
ユーザー twooimp2
提出日時 2024-06-08 13:34:24
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 3,782 ms
コンパイル使用メモリ 254,580 KB
実行使用メモリ 16,420 KB
最終ジャッジ日時 2024-12-27 22:09:56
合計ジャッジ時間 7,589 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  map<ll,ll> mpl,mpr;
  ll cnt=0;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    mpr[a[i]]++;
    if(mpr[a[i]]==2){
      cnt++;
    }
  }
  vector<ll> ans;
  for(ll i=0;i<n-1;i++){
    mpr[a[i]]--;
    if(mpr[a[i]]==1){
      cnt--;
    }
    mpl[a[i]]++;
    if(mpl[a[i]]==2){
      break;
    }
    if(cnt==0){
      ans.push_back(i+1);
    }
  }
  cout<<ans.size()<<endl;
  for(ll i=0;i<(ll)ans.size();i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}
0