結果
| 問題 |
No.2779 Don't make Pair
|
| コンテスト | |
| ユーザー |
やまひろ
|
| 提出日時 | 2024-06-19 02:11:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 463 ms / 2,000 ms |
| コード長 | 1,108 bytes |
| コンパイル時間 | 4,982 ms |
| コンパイル使用メモリ | 242,440 KB |
| 実行使用メモリ | 23,856 KB |
| 最終ジャッジ日時 | 2024-06-19 02:11:26 |
| 合計ジャッジ時間 | 11,177 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint1000000007;
const ll inf = 9e18;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
vector<ll> a(n);
map<ll,ll> g1,g2;
map<ll,bool> is_separated;
ll cnt=0;
for(ll i=0;i<n;i++){
cin >> a[i];
g2[a[i]]++;
g1[a[i]]=0;
if(g2[a[i]]==1){
is_separated[a[i]]=true;
cnt++;
}
if(g2[a[i]]>=2){
is_separated[a[i]]=false;
cnt--;
}
}
vector<ll> ans;
for(ll i=0;i<n-1;i++){
g1[a[i]]++;
g2[a[i]]--;
if(is_separated[a[i]]==false&&g1[a[i]]<=1&&g2[a[i]]<=1){
cnt++;
is_separated[a[i]]=true;
}
if(is_separated[a[i]]==true&&(g1[a[i]]>=2||g2[a[i]]>=2)){
cnt--;
is_separated[a[i]]=false;
}
if(cnt==is_separated.size()) ans.push_back(i+1);
}
cout << ans.size() << endl;
for(ll idx:ans) cout << idx << " ";
cout << endl;
}
やまひろ