萌新WA 求助大佬
查看原帖
萌新WA 求助大佬
595684
AceTaffy812楼主2024/12/12 19:17

迷惑喵喵

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define RI register int
using namespace std;
int n;
string a, b;

void era(string &s)
{
    string result;
    for (int i = 0; i < s.size();)
    {
        if (i < s.size() - 2 and (((s[i] == 'A') and (s[i + 1] == 'B') and (s[i + 2] == 'C')) or ((s[i] == 'B') and (s[i + 1] == 'C') and (s[i + 2] == 'A')) or ((s[i] == 'C') and (s[i + 1] == 'A') and (s[i + 2] == 'B'))))
        {
            i += 3;
        }
        else
        {
            result += s[i];
            i++;
        }
    }
    s = result;
    //cout << s << endl;
}

int main()
{
    cin >> n >> a >> b;
    era(a);
    era(b);
    if (a == b)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

2024/12/12 19:17
加载中...