Submission #73686205


Source Code Expand

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
//#include <numeric>
#include <queue>
//#include <ranges>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define pb push_back
#define fr first
#define sc second
#define sor(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int,int>;
//using pll = pair<ll,ll>;
//using pqdec = priority_queue<int,vector<int>,greater<int>>;
//using pqdecl = priority_queue<ll,vector<ll>,greater<ll>>;
template <typename T>
using graph = vector<vector<T>>;
const ll LLMAX = 9223372*1e10;
const int IMAX = 214*1e7;
/*--------考察--------------------
----------CODING----------------*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    string ss,tt;
    rep(i,ssize(s)){
        if(s[i]!='A') ss.pb(s[i]);
    }
    rep(i,ssize(t)){
        if(t[i] !='A') tt.pb(t[i]);
    }
    if(ss != tt){
        cout << -1 << endl;
        return 0;
    }
    vector<int> sv(1),tv(1);
    int idx = 0;
    rep(i,ssize(s)){
        if(s[i] =='A') sv[idx]++;
        else{
            idx++;
            sv.pb(0);
        }
    }
    idx = 0;
    rep(i,ssize(t)){
        if(t[i] =='A') tv[idx]++;
        else{
            idx++;
            tv.pb(0);
        }
    }
    int ans = 0;
    rep(i,ssize(sv)){
        ans += abs(sv[i] - tv[i]);
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Insert and Erase A
User scotch_at
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1604 Byte
Status AC
Exec Time 6 ms
Memory 8844 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 3592 KiB
00_sample_01.txt AC 1 ms 3556 KiB
00_sample_02.txt AC 1 ms 3556 KiB
00_sample_03.txt AC 1 ms 3624 KiB
01_random_00.txt AC 1 ms 3916 KiB
01_random_01.txt AC 2 ms 3844 KiB
01_random_02.txt AC 3 ms 4716 KiB
02_random2_00.txt AC 3 ms 6364 KiB
02_random2_01.txt AC 3 ms 4292 KiB
02_random2_02.txt AC 6 ms 6844 KiB
02_random2_03.txt AC 6 ms 7108 KiB
02_random2_04.txt AC 5 ms 6216 KiB
02_random2_05.txt AC 3 ms 4660 KiB
02_random2_06.txt AC 5 ms 6964 KiB
02_random2_07.txt AC 3 ms 4372 KiB
02_random2_08.txt AC 5 ms 5064 KiB
02_random2_09.txt AC 6 ms 5312 KiB
02_random2_10.txt AC 5 ms 6540 KiB
02_random2_11.txt AC 5 ms 6944 KiB
03_random3_00.txt AC 3 ms 4976 KiB
03_random3_01.txt AC 3 ms 4200 KiB
03_random3_02.txt AC 3 ms 4412 KiB
03_random3_03.txt AC 4 ms 4296 KiB
04_handmade_00.txt AC 1 ms 3556 KiB
04_handmade_01.txt AC 1 ms 3404 KiB
04_handmade_02.txt AC 1 ms 3496 KiB
04_handmade_03.txt AC 1 ms 3636 KiB
04_handmade_04.txt AC 5 ms 8844 KiB
04_handmade_05.txt AC 2 ms 4676 KiB
04_handmade_06.txt AC 2 ms 4672 KiB
04_handmade_07.txt AC 3 ms 4272 KiB
04_handmade_08.txt AC 2 ms 3784 KiB
04_handmade_09.txt AC 2 ms 3956 KiB