結果
| 問題 |
No.2779 Don't make Pair
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-07 21:41:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 127 ms / 2,000 ms |
| コード長 | 970 bytes |
| コンパイル時間 | 2,199 ms |
| コンパイル使用メモリ | 202,340 KB |
| 最終ジャッジ日時 | 2025-02-21 20:03:42 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
for(T& x : vec) is >> x;
return is;
}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
if(vec.empty()) return os;
os << vec[0];
for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
return os;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
cin >> a;
map<int,int> mp, mp2;
int r = -1;
for(int i = 0; i < n; i++){
mp[a[i]]++;
if(mp[a[i]] == 1) r = i + 1;
else break;
}
int l = n;
for(int i = n - 1; i >= 0; i--){
mp2[a[i]]++;
if(mp2[a[i]] == 1) l = i;
else break;
}
vector<int> ans;
for(int i = max(1, l); i <= r && i <= n - 1; i++){
ans.push_back(i);
}
cout << ans.size() << '\n' << ans << '\n';
}