56082023-08-03 01:11:11lazingergoTükörtojás (75 pont)cpp17Time limit exceeded 40/75349ms3772 KiB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <stack>
#include <queue>

#define ll long long
#define ull unsigned long lon
#define vi vector<int>

using namespace std;

void solve()
{
    int n;
    cin>>n;
    int* aktualis=new int[n];
    int* elvart=new int[n];
    for(int i=0; i<n; i++)
    {
        char a;
        cin>>a;
        if(a=='S')
            aktualis[i]=0;
        else
            aktualis[i]=1;
    }

    for(int i=0; i<n; i++)
    {
        char a;
        cin>>a;
        if(a=='S')
            elvart[i]=0;
        else
            elvart[i]=1;
    }

    int kivalasztott=0;
    int nr=0;
    while(kivalasztott!=-1)
    {
        kivalasztott=-1;
        for(int i=n-1; i>=0; i--)
        {
            if(aktualis[i]!=elvart[i])
            {
                kivalasztott=i;
                nr++;
                aktualis[i]=elvart[i];
                break;
            }
        }
        if(kivalasztott!=-1) 
        {
            for(int i=0; i<kivalasztott; i++)
            {
                if(aktualis[i]==1)
                {
                    aktualis[i]=0;
                }
                else
                {
                    aktualis[i]=1;
                }
            }
        }

    }
    cout<<nr<<endl;

}

int main()
{
    

  //  while(t--)
    {
        solve();
    }
}
SubtaskSumTestVerdictTimeMemory
base40/75
1Accepted0/03ms1872 KiB
2Time limit exceeded0/0300ms1708 KiB
3Time limit exceeded0/5300ms1712 KiB
4Accepted5/53ms2304 KiB
5Accepted5/53ms2512 KiB
6Accepted5/52ms2576 KiB
7Accepted5/53ms2700 KiB
8Accepted5/53ms2928 KiB
9Accepted5/53ms3008 KiB
10Accepted5/53ms3136 KiB
11Accepted5/53ms3344 KiB
12Time limit exceeded0/5300ms3336 KiB
13Time limit exceeded0/5349ms3640 KiB
14Time limit exceeded0/5257ms3460 KiB
15Time limit exceeded0/5264ms3528 KiB
16Time limit exceeded0/5268ms3740 KiB
17Time limit exceeded0/5268ms3772 KiB