Submission #73684032


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;

using i128 = __int128;
using u128 = unsigned __int128;

mt19937_64 mrand((u64)random_device{}() << 32 ^ random_device{}() ^
	chrono::high_resolution_clock::now().time_since_epoch().count());
template<class T = i64,class T2>T rnd(T l,T2 r){
return uniform_int_distribution<T>(l,r)(mrand);}

int main (){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);

	string s,t;
	cin >> s >> t;

	auto era = [&](string s){
		string str;

		for (auto i:s)
			if (i != 'A')
				str += i;

		return str;
	};

	if (era(s) != era(t)){
		cout << "-1\n";
		return 0;
	}

	int i = 0,j = 0,n = s.size(),m = t.size();

	int ans = 0;

	for (;i < n&&j < m;){
		if (s[i] == t[j]){i++,j++;continue;}
		ans++;
		if (s[i] == 'A') i++;
		else j++;
	}

	cout << ans + n - i + m - j;
}

Submission Info

Submission Time
Task C - Insert and Erase A
User zyx2012
Language C++23 (GCC 15.2.0)
Score 300
Code Size 927 Byte
Status AC
Exec Time 6 ms
Memory 5608 KiB

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 1 ms 3548 KiB
00_sample_01.txt AC 1 ms 3540 KiB
00_sample_02.txt AC 1 ms 3604 KiB
00_sample_03.txt AC 1 ms 3604 KiB
01_random_00.txt AC 1 ms 3880 KiB
01_random_01.txt AC 2 ms 4276 KiB
01_random_02.txt AC 3 ms 5608 KiB
02_random2_00.txt AC 2 ms 4644 KiB
02_random2_01.txt AC 4 ms 4532 KiB
02_random2_02.txt AC 5 ms 5436 KiB
02_random2_03.txt AC 5 ms 5168 KiB
02_random2_04.txt AC 4 ms 4660 KiB
02_random2_05.txt AC 3 ms 4352 KiB
02_random2_06.txt AC 4 ms 4896 KiB
02_random2_07.txt AC 3 ms 4136 KiB
02_random2_08.txt AC 5 ms 4780 KiB
02_random2_09.txt AC 6 ms 4788 KiB
02_random2_10.txt AC 3 ms 4904 KiB
02_random2_11.txt AC 4 ms 5260 KiB
03_random3_00.txt AC 3 ms 5496 KiB
03_random3_01.txt AC 3 ms 4548 KiB
03_random3_02.txt AC 3 ms 4860 KiB
03_random3_03.txt AC 4 ms 4764 KiB
04_handmade_00.txt AC 1 ms 3504 KiB
04_handmade_01.txt AC 1 ms 3500 KiB
04_handmade_02.txt AC 1 ms 3504 KiB
04_handmade_03.txt AC 1 ms 3500 KiB
04_handmade_04.txt AC 4 ms 5524 KiB
04_handmade_05.txt AC 3 ms 5188 KiB
04_handmade_06.txt AC 3 ms 4896 KiB
04_handmade_07.txt AC 2 ms 4516 KiB
04_handmade_08.txt AC 2 ms 4000 KiB
04_handmade_09.txt AC 2 ms 3984 KiB