結果
| 問題 |
No.2779 Don't make Pair
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-04 00:44:31 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 173 ms / 2,000 ms |
| コード長 | 841 bytes |
| コンパイル時間 | 3,153 ms |
| コンパイル使用メモリ | 256,888 KB |
| 実行使用メモリ | 16,692 KB |
| 最終ジャッジ日時 | 2024-07-04 00:44:38 |
| 合計ジャッジ時間 | 6,081 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 24 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#ifdef LOCAL
#include <algo/debug.h>
#else
#define debug(...) void(0)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N; cin >> N;
vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
map<ll, ll> MP1, MP2; for(int i = 0; i < N; i++) MP2[A[i]]++;
int s1 = 0, s2 = 0;
for(auto&&[a, b]: MP2) {
if(b >= 2) {
s2++;
}
}
vector<int> ans;
for(int i = 0; i < N - 1; i++) {
MP2[A[i]]--; MP1[A[i]]++;
if(MP2[A[i]] == 1) s2--;
if(MP1[A[i]] == 2) s1++;
if(s1 == 0 && s2 == 0) {
ans.push_back(i + 1);
}
}
cout << int(ans.size()) << endl;
for(auto&&a : ans) {
cout << a << " ";
}cout << endl;
}