結果

問題 No.2779 Don't make Pair
ユーザー テナガザルテナガザル
提出日時 2024-06-13 20:12:06
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 114,840 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-06-13 20:12:12
合計ジャッジ時間 4,637 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	map<int, vector<int>> mp;
	for (int i = 0; i < n; ++i) mp[a[i]].push_back(i);
	for (auto v : mp)
	{
		if (v.second.size() > 2)
		{
			cout << "0\n" << endl;
			return 0;
		}
	}
	int mal = 0, mir = n - 1;
	for (auto v : mp)
	{
		if (v.second.size() == 1) continue;
		mal = max(mal, v.second[0]);
		mir = min(mir, v.second[1]);
	}
	cout << max(mir - mal, 0) << endl;
	for (int i = mal; i < mir; ++i) cout << i + 1 << ' ';
	cout << endl;
}
0