Submission #73692074


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

char s[300010], t[300010];
vector <int> a, b;

int main() {
	scanf("%s%s", s + 1, t + 1);
	int n = strlen(s + 1), m = strlen(t + 1), r = 1;
	a.push_back(0), b.push_back(0);
	for (int i = 1 ; i <= n ; i++) if (s[i] != 'A') {
		while (r <= m && t[r] == 'A') ++r;
		if (r > m || t[r] != s[i]) return puts("-1") & 0;
		a.push_back(i), b.push_back(r);
		++r;
	}
	while (r <= m && t[r] == 'A') ++r;
	if (r <= m) return puts("-1") & 0;
	a.push_back(n + 1), b.push_back(m + 1);
//	cout << a.size() << " " << b.size() << endl;
//	assert(a.size() != b.size());
	int k = a.size(), ans = 0;
	for (int i = 0 ; i < k - 1 ; i++)
		ans += abs(a[i + 1] - a[i] - 1 - (b[i + 1] - b[i] - 1));
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Insert and Erase A
User dongzirui0817
Language C++ IOI-Style(GNU++20) (GCC 14.2.0)
Score 300
Code Size 803 Byte
Status AC
Exec Time 5 ms
Memory 5468 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%s%s", s + 1, t + 1);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt, 04_handmade_05.txt, 04_handmade_06.txt, 04_handmade_07.txt, 04_handmade_08.txt, 04_handmade_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 0 ms 1736 KiB
00_sample_01.txt AC 0 ms 1736 KiB
00_sample_02.txt AC 0 ms 1736 KiB
00_sample_03.txt AC 0 ms 1736 KiB
01_random_00.txt AC 1 ms 1864 KiB
01_random_01.txt AC 1 ms 1992 KiB
01_random_02.txt AC 1 ms 2376 KiB
02_random2_00.txt AC 3 ms 3748 KiB
02_random2_01.txt AC 2 ms 2632 KiB
02_random2_02.txt AC 4 ms 4316 KiB
02_random2_03.txt AC 4 ms 4060 KiB
02_random2_04.txt AC 3 ms 3804 KiB
02_random2_05.txt AC 2 ms 2632 KiB
02_random2_06.txt AC 4 ms 3852 KiB
02_random2_07.txt AC 2 ms 2504 KiB
02_random2_08.txt AC 3 ms 3104 KiB
02_random2_09.txt AC 4 ms 3252 KiB
02_random2_10.txt AC 3 ms 3932 KiB
02_random2_11.txt AC 4 ms 4288 KiB
03_random3_00.txt AC 2 ms 3152 KiB
03_random3_01.txt AC 3 ms 3016 KiB
03_random3_02.txt AC 3 ms 3836 KiB
03_random3_03.txt AC 1 ms 2376 KiB
04_handmade_00.txt AC 0 ms 1736 KiB
04_handmade_01.txt AC 0 ms 1736 KiB
04_handmade_02.txt AC 0 ms 1736 KiB
04_handmade_03.txt AC 0 ms 1736 KiB
04_handmade_04.txt AC 5 ms 5468 KiB
04_handmade_05.txt AC 1 ms 2376 KiB
04_handmade_06.txt AC 1 ms 2376 KiB
04_handmade_07.txt AC 2 ms 2376 KiB
04_handmade_08.txt AC 1 ms 1992 KiB
04_handmade_09.txt AC 1 ms 1992 KiB