Submission #73536315


Source Code Expand

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, t, a[400005], cnt;
int flg[200005], u[400005];
vector<int> ans;
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> t;
	while(t --) {
		cin >> n;
		ans.clear();
		for(int i = 1; i <= n; i ++) flg[i] = u[i] = 0;
		for(int i = 1; i <= 2 * n; i ++) {
			cin >> a[i];
		}
		flg[a[1]] = 1;
		for(int i = 2; i <= 2 * n; i ++) {
			if(!flg[a[i]]) u[i] = u[i - 1], flg[a[i]] = i;
			else {
				u[i] = !u[flg[a[i]]];
				if(u[i] != u[i - 1]) ans.push_back(i - 1);
			}
		}
		cout << ans.size() << '\n';
		for(auto i : ans) cout << i << ' ';
		cout << '\n';
	}
	return 0;
}

Submission Info

Submission Time
Task B - Stolen Necklace
User WangYueHeng
Language C++23 (GCC 15.2.0)
Score 500
Code Size 692 Byte
Status AC
Exec Time 25 ms
Memory 13316 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 1
AC × 20
Set Name Test Cases
Sample 00_sample_01.txt
All 00_sample_01.txt, hand-14.txt, hand-15.txt, hand-16.txt, hand-17.txt, max-12.txt, min-13.txt, nyaan_killer-19.txt, random-01.txt, random-02.txt, random-03.txt, random-04.txt, random-05.txt, random-06.txt, random-07.txt, random-08.txt, random-09.txt, random-10.txt, random-11.txt, random-18.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3516 KiB
hand-14.txt AC 24 ms 12940 KiB
hand-15.txt AC 23 ms 12904 KiB
hand-16.txt AC 23 ms 13172 KiB
hand-17.txt AC 23 ms 13168 KiB
max-12.txt AC 23 ms 12820 KiB
min-13.txt AC 16 ms 11352 KiB
nyaan_killer-19.txt AC 21 ms 13316 KiB
random-01.txt AC 24 ms 7772 KiB
random-02.txt AC 17 ms 3772 KiB
random-03.txt AC 18 ms 3736 KiB
random-04.txt AC 20 ms 4668 KiB
random-05.txt AC 20 ms 5860 KiB
random-06.txt AC 20 ms 7808 KiB
random-07.txt AC 25 ms 11980 KiB
random-08.txt AC 25 ms 11960 KiB
random-09.txt AC 25 ms 11960 KiB
random-10.txt AC 25 ms 12016 KiB
random-11.txt AC 25 ms 12044 KiB
random-18.txt AC 10 ms 3736 KiB