Submission details
Task:Babaza Game
Sender:datxaban
Submission time:2025-09-01 17:42:43 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#40.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#120.00 sdetails
#13ACCEPTED0.00 sdetails
#140.00 sdetails

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:129:9: warning: unused variable 'cnt' [-Wunused-variable]
  129 |     int cnt = 0;
      |         ^~~

Code

/*
    Road to Freedom
*/

#include <bits/stdc++.h>

using namespace std;

#define ll             long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
#define REP(i,a,b)     for (int i = a; i <= b; i++)

inline int power(int a, int b)
{
    int x = 1;
    while (b)
    {
        if (b & 1) x *= a;
        a *= a;
        b >>= 1;
    }
    return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


void babazaHelper(string s1, string s2){
    int n = s1.size();
    // change all even one
    if(s1[0] != s2[0]){
        if(s1[1] == s2[0]){
            char tmp = s1[1] + 1;
            if(tmp == 'Z' + 1){
                tmp = 'Z' - 1;
            }
            s1[0] = tmp;
        }
        else {
            s1[0] = s2[0];
        }
    }
    for(int i = 2; i < n - 1; i+=2){
        if(s2[i] != s1[i-1] && s2[i]!= s1[i+1]){
            s1[i] = s2[i];
        }
        else{
            char tmp = s2[i] + 1;
            if(tmp == 'Z' + 1){
                tmp = 'Z' - 1;
            }
            s1[i] = tmp;
        }
    }

    if(n%2 == 1){
        if(s1[n-1] != s2[n-2]){
            s1[n-1] = s2[n-1];
        }
    }

    cout << s1 << endl;


    // change odd one

    for(int i = 1; i < n - 1; i+=2){
        if(s2[i] != s1[i-1] && s2[i]!= s1[i+1]){
            s1[i] = s2[i];
        }
        else{
            char tmp = s2[i] + 1;
            if(tmp == 'Z' + 1){
                tmp = 'Z' - 1;
            }
            s1[i] = tmp;
        }
    }

    if(n%2 == 0){
        if(s1[n-1] != s2[n-1]){
            s1[n-1] = s2[n-1];
        }
    }
    if(s1 == s2) return;
    cout << s1 << endl;
}


void solve() {
    /*
        the problem always return maximum 4 strings
    */
    string s1, s2;
    cin >> s1 >> s2;

    //edge case
    if(s1.size() == 1){
        cout << s1 << endl << s2; return;
    }

    int cnt = 0;
    
    cout << s1 << endl;
    babazaHelper(s1, s2);
    cout << s2 << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif

    clock_t z = clock();

    int t = 1;
    // cin >> t;
    while (t--) solve();

    cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
A
B

correct output
A
B

user output
A
B

Error:
Run Time : 3.3e-05

Test 2

Verdict: ACCEPTED

input
BABAZA
BACBCB

correct output
BABAZA
BACACA
BACBCB

user output
BABAZA
BACACA
BACBCB

Error:
Run Time : 3.3e-05

Test 3

Verdict: ACCEPTED

input
AB
BA

correct output
AB
CB
CA
BA

user output
AB
CB
CA
BA

Error:
Run Time : 3.4e-05

Test 4

Verdict:

input
ABC
BCD

correct output
ABC
DBD
DCD
BCD

user output
ABC
CBC
CDC
BCD

Error:
Run Time : 3.4e-05

Test 5

Verdict:

input
AXYB
CXYD

correct output
AXYB
CXYD

user output
AXYB
CXYB
CXYD

Error:
Run Time : 3.3e-05

Test 6

Verdict: ACCEPTED

input
LMIJLF
PAQBMH

correct output
LMIJLF
PMQJMF
PAQBMH

user output
LMIJLF
PMQJMF
PAQBMH

Error:
Run Time : 3.3e-05

Test 7

Verdict:

input
PNIWLSLIH
CRLVPUFHD

correct output
PNIWLSLIH
CNLWPSFID
CRLVPUFHD

user output
PNIWLSLIH
CNLWPSFIH
CRLVPUFIH
CRLVPUFHD

Error:
Run Time : 3.2e-05

Test 8

Verdict: ACCEPTED

input
ZDYIAVTKL
ZJKVXGAUM

correct output
ZDYIAVTKL
ZJYVAGTUL
ZJKVXGAUM

user output
ZDYIAVTKL
ZDKIXVAKM
ZJKVXGAUM

Error:
Run Time : 3.3e-05

Test 9

Verdict: ACCEPTED

input
FBIXISJH
NXZIESMG

correct output
FBIXISJH
NBZXESMH
NXZIESMG

user output
FBIXISJH
NBZXESMH
NXZIESMG

Error:
Run Time : 3.5e-05

Test 10

Verdict: ACCEPTED

input
OPGW
QJIE

correct output
OPGW
QPIW
QJIE

user output
OPGW
QPIW
QJIE

Error:
Run Time : 3.3e-05

Test 11

Verdict: ACCEPTED

input
DUKNPKQZBL
NZPBMOEBIC

correct output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

user output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

Error:
Run Time : 3.4e-05

Test 12

Verdict:

input
ZWDTX
HZOXI

correct output
ZWDTX
HWOTI
HZOXI

user output
ZWDTX
HWOTX
HZOYX
HZOXI

Error:
Run Time : 3.4e-05

Test 13

Verdict: ACCEPTED

input
URJF
ITIQ

correct output
URJF
IRIF
ITIQ

user output
URJF
IRIF
ITIQ

Error:
Run Time : 3.3e-05

Test 14

Verdict:

input
WYWBWU
IRYVBA

correct output
WYWBWU
WRWVWA
IRYVBA

user output
WYWBWU
IYZBCU
IRZVCA
IRYVBA

Error:
Run Time : 3.3e-05