Submission #64145425


Source Code Expand

#include <bits/stdc++.h>
#define multiple_cases(T) signed T; cin >> T; while (T--)
using namespace std;
int n, a[1000005], ans;
signed main() {
	multiple_cases(T)
	{
		cin >> n;
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		a[n + 1] = a[n + 2] = a[n + 3] = a[n + 4] = 0;
		ans = 0;
		for (int i = 1; i <= n; i++) {
			if (a[i + 1] != a[i]) {
				if (a[i + 2] == a[i] && a[i + 2] != a[i + 3] && a[i + 1] == a[i + 3]) {
					// cout << i << endl;
					swap(a[i + 1], a[i + 2]);
					i++;
					ans++;
				}
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task D - Swap and Erase
User EricWan
Language C++ 20 (gcc 12.2)
Score 0
Code Size 601 Byte
Status WA
Exec Time 126 ms
Memory 4456 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 1
AC × 17
WA × 43
Set Name Test Cases
Sample 00_sample_01.txt
All 00_sample_01.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 02_tiny_01.txt, 02_tiny_02.txt, 02_tiny_03.txt, 02_tiny_04.txt, 02_tiny_05.txt, 02_tiny_06.txt, 02_tiny_07.txt, 02_tiny_08.txt, 02_tiny_09.txt, 02_tiny_10.txt, 03_small_01.txt, 03_small_02.txt, 03_small_03.txt, 03_small_04.txt, 03_small_05.txt, 04_medium_01.txt, 04_medium_02.txt, 04_medium_03.txt, 04_medium_04.txt, 04_medium_05.txt, 05_large_01.txt, 05_large_02.txt, 05_large_03.txt, 05_large_04.txt, 05_large_05.txt, 06_max_01.txt, 06_max_02.txt, 06_max_03.txt, 06_max_04.txt, 06_max_05.txt, 07_small_few_types_01.txt, 07_small_few_types_02.txt, 07_small_few_types_03.txt, 07_small_few_types_04.txt, 07_small_few_types_05.txt, 08_medium_few_types_01.txt, 08_medium_few_types_02.txt, 08_medium_few_types_03.txt, 08_medium_few_types_04.txt, 08_medium_few_types_05.txt, 09_large_few_types_01.txt, 09_large_few_types_02.txt, 09_large_few_types_03.txt, 09_large_few_types_04.txt, 09_large_few_types_05.txt, 10_max_few_types_01.txt, 10_max_few_types_02.txt, 10_max_few_types_03.txt, 10_max_few_types_04.txt, 10_max_few_types_05.txt, 10_max_few_types_06.txt, 10_max_few_types_07.txt, 10_max_few_types_08.txt, 10_max_few_types_09.txt, 10_max_few_types_10.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3588 KiB
01_handmade_01.txt AC 1 ms 3480 KiB
01_handmade_02.txt AC 126 ms 3484 KiB
01_handmade_03.txt AC 36 ms 4268 KiB
01_handmade_04.txt AC 34 ms 4232 KiB
02_tiny_01.txt WA 41 ms 3448 KiB
02_tiny_02.txt WA 41 ms 3452 KiB
02_tiny_03.txt WA 40 ms 3480 KiB
02_tiny_04.txt WA 40 ms 3544 KiB
02_tiny_05.txt WA 40 ms 3588 KiB
02_tiny_06.txt WA 40 ms 3528 KiB
02_tiny_07.txt WA 40 ms 3492 KiB
02_tiny_08.txt WA 40 ms 3612 KiB
02_tiny_09.txt WA 40 ms 3516 KiB
02_tiny_10.txt WA 41 ms 3480 KiB
03_small_01.txt WA 26 ms 3524 KiB
03_small_02.txt WA 27 ms 3404 KiB
03_small_03.txt WA 26 ms 3408 KiB
03_small_04.txt WA 27 ms 3444 KiB
03_small_05.txt WA 25 ms 3484 KiB
04_medium_01.txt WA 26 ms 3496 KiB
04_medium_02.txt WA 27 ms 3548 KiB
04_medium_03.txt WA 27 ms 3496 KiB
04_medium_04.txt WA 26 ms 3476 KiB
04_medium_05.txt AC 27 ms 3688 KiB
05_large_01.txt AC 10 ms 3604 KiB
05_large_02.txt AC 33 ms 4132 KiB
05_large_03.txt AC 33 ms 4180 KiB
05_large_04.txt AC 34 ms 4192 KiB
05_large_05.txt AC 14 ms 3804 KiB
06_max_01.txt AC 35 ms 4292 KiB
06_max_02.txt AC 35 ms 4248 KiB
06_max_03.txt AC 34 ms 4228 KiB
06_max_04.txt AC 35 ms 4304 KiB
06_max_05.txt AC 34 ms 4264 KiB
07_small_few_types_01.txt WA 26 ms 3676 KiB
07_small_few_types_02.txt WA 26 ms 3588 KiB
07_small_few_types_03.txt WA 26 ms 3484 KiB
07_small_few_types_04.txt WA 27 ms 3472 KiB
07_small_few_types_05.txt WA 26 ms 3464 KiB
08_medium_few_types_01.txt WA 27 ms 3476 KiB
08_medium_few_types_02.txt WA 27 ms 3492 KiB
08_medium_few_types_03.txt WA 27 ms 3456 KiB
08_medium_few_types_04.txt WA 27 ms 3460 KiB
08_medium_few_types_05.txt WA 26 ms 3496 KiB
09_large_few_types_01.txt WA 26 ms 3768 KiB
09_large_few_types_02.txt WA 27 ms 3792 KiB
09_large_few_types_03.txt WA 29 ms 4112 KiB
09_large_few_types_04.txt WA 32 ms 3968 KiB
09_large_few_types_05.txt WA 19 ms 3920 KiB
10_max_few_types_01.txt AC 19 ms 4296 KiB
10_max_few_types_02.txt WA 19 ms 4296 KiB
10_max_few_types_03.txt WA 19 ms 4456 KiB
10_max_few_types_04.txt WA 20 ms 4224 KiB
10_max_few_types_05.txt WA 19 ms 4312 KiB
10_max_few_types_06.txt WA 19 ms 4248 KiB
10_max_few_types_07.txt WA 18 ms 4296 KiB
10_max_few_types_08.txt WA 19 ms 4184 KiB
10_max_few_types_09.txt WA 19 ms 4292 KiB
10_max_few_types_10.txt WA 19 ms 4232 KiB