結果
| 問題 | No.2779 Don't make Pair |
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2024-06-07 21:34:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 552 ms / 2,000 ms |
| コード長 | 1,874 bytes |
| 記録 | |
| コンパイル時間 | 4,460 ms |
| コンパイル使用メモリ | 261,448 KB |
| 最終ジャッジ日時 | 2025-02-21 19:55:16 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 24 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
int main(){
int n; cin >> n;
vector<int> a(n);
rep(i,0,n){
cin >> a[i];
}
map<int,int> mp1;
map<int,int> mp2;
multiset<int> st1;
multiset<int> st2;
rep(i,0,n){
if(mp2.find(a[i]) == mp2.end()){
st2.insert(0);
}
st2.erase(st2.find(mp2[a[i]]));
mp2[a[i]]++;
st2.insert(mp2[a[i]]);
}
vector<int> ans;
rep(i,0,n-1){
if(mp1.find(a[i]) == mp1.end()){
st1.insert(0);
}
if(mp2.find(a[i]) == mp2.end()){
st2.insert(0);
}
st1.erase(st1.find(mp1[a[i]]));
mp1[a[i]]++;
st1.insert(mp1[a[i]]);
st2.erase(st2.find(mp2[a[i]]));
mp2[a[i]]--;
st2.insert(mp2[a[i]]);
auto itr1 = st1.end();
auto itr2 = st2.end();
itr1--;
itr2--;
if (max(*itr1, *itr2) == 1){
ans.push_back(i+1);
}
}
int m = ans.size();
cout << m << '\n';
for (int x: ans){
cout << x << ' ';
}
cout << '\n';
}
shobonvip