結果
問題 | No.2779 Don't make Pair |
ユーザー | t98slider |
提出日時 | 2024-06-07 21:41:28 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 970 bytes |
コンパイル時間 | 3,517 ms |
コンパイル使用メモリ | 210,224 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-12-26 07:30:03 |
合計ジャッジ時間 | 4,948 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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'; }