結果

問題 No.2779 Don't make Pair
ユーザー テナガザルテナガザル
提出日時 2024-06-13 20:12:06
言語 C++23
(gcc 12.3.0 + boost 1.83.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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 7 ms
6,940 KB
testcase_10 AC 32 ms
6,940 KB
testcase_11 AC 11 ms
6,940 KB
testcase_12 AC 43 ms
8,572 KB
testcase_13 AC 47 ms
8,936 KB
testcase_14 AC 36 ms
6,940 KB
testcase_15 AC 80 ms
11,776 KB
testcase_16 AC 86 ms
12,424 KB
testcase_17 AC 55 ms
9,456 KB
testcase_18 AC 41 ms
8,064 KB
testcase_19 AC 65 ms
10,516 KB
testcase_20 AC 29 ms
6,944 KB
testcase_21 AC 118 ms
14,464 KB
testcase_22 AC 108 ms
14,592 KB
testcase_23 AC 115 ms
14,592 KB
testcase_24 AC 107 ms
14,592 KB
testcase_25 AC 112 ms
14,592 KB
testcase_26 AC 144 ms
14,592 KB
testcase_27 AC 107 ms
14,592 KB
testcase_28 AC 105 ms
14,592 KB
権限があれば一括ダウンロードができます

ソースコード

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