CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Babaza Game
Sender:auni
Submission time:2024-09-02 17:49:31 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#90.00 sdetails
#10ACCEPTED0.00 sdetails
#110.00 sdetails
#120.01 sdetails
#13ACCEPTED0.00 sdetails
#140.00 sdetails

Code

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,a,b) for (int i = a; i < b; i++)


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

    string a, b;
    cin >> a >> b;
    int n = a.length();

    cout << a << "\n";

    bool canEven = true;
    for(int i = 0; i < n; i+=2) {
        if(a[i] != b[i]) {
            canEven = false;
        }
    }

    bool canOdd = true;
    for(int i = 1; i < n; i+=2) {
        if(a[i] != b[i]) {
            canOdd = false;
        }
    }

    if(canOdd & canEven) {

    } else if(canOdd) {
        for(int i = 0; i < n; i+=2) {
            a[i] = b[i];
        }
    
        cout << a << "\n";

    } else if(canEven) {
        for(int i = 1; i < n; i+=2) {
            a[i] = b[i];
        }
        
        cout << a << "\n";
    } else {
        // CORE HERE
        canOdd = true;
        canEven = true;
        for(int i = 1; i < n; i+=2) {
            if((i != n-1) && ((b[i] == a[i-1]) || (b[i] == a[i+1]))) {
                canOdd = false;
            } else if((i == n-1) && (b[i] == a[i-1])) {
                canOdd = false;
            }

        }
        for(int i = 0; i < n; i+=2) {
            if(((i != 0) && (i != n-1)) && ((b[i] == a[i-1]) || (b[i] == a[i+1]))) {
                canEven = false;
            } else if(((i == 0) && (i != n-1)) && (b[i] == a[i+1])) {
                canEven = false;
            } else if(((i != 0) && (i == n-1)) && (b[i] == a[i-1])) {
                canEven = false;
            }
        }
        // CORE HERE
        if(canOdd) {
            
            for(int i = 0; i < n; i+=2) {
                a[i] = b[i];
            }
            cout << a << "\n";
            for(int i = 1; i < n; i+=2) {
                a[i] = b[i];
            }
            cout << a << "\n";
        } else if(canEven) {
            
            for(int i = 1; i < n; i+=2) {
                a[i] = b[i];
            }
            cout << a << "\n";
            for(int i = 0; i < n; i+=2) {
                a[i] = b[i];
            }
            cout << a << "\n";
        } else {
            bool found = false;
            char c = 'A'-1;

            while(!found) {
                ++c;
                found = true;
                for(int j = 0; j < n; ++j) {
                    if(a[j] == c || b[j] == c) {
                        found = false;
                        break;
                    }
                }
            }
            for(int i = 0; i < n; i+=2) {
                a[i] = c;
            }
            cout << a << "\n";
            for(int i = 1; i < n; i+=2) {
                a[i] = b[i];
            }
            cout << a << "\n";
            for(int i = 0; i < n; i+=2) {
                a[i] = b[i];
            }
            cout << a << "\n";
        }

    }

    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
A
B

correct output
A
B

user output
A
B

Test 2

Verdict:

input
BABAZA
BACBCB

correct output
BABAZA
BACACA
BACBCB

user output
BABAZA
BABBZB
BACBCB

Test 3

Verdict: ACCEPTED

input
AB
BA

correct output
AB
CB
CA
BA

user output
AB
CB
CA
BA

Test 4

Verdict: ACCEPTED

input
ABC
BCD

correct output
ABC
DBD
DCD
BCD

user output
ABC
EBE
ECE
BCD

Test 5

Verdict:

input
AXYB
CXYD

correct output
AXYB
CXYD

user output
AXYB
CXYB
CXYD

Test 6

Verdict: ACCEPTED

input
LMIJLF
PAQBMH

correct output
LMIJLF
PMQJMF
PAQBMH

user output
LMIJLF
PMQJMF
PAQBMH

Test 7

Verdict:

input
PNIWLSLIH
CRLVPUFHD

correct output
PNIWLSLIH
CNLWPSFID
CRLVPUFHD

user output
PNIWLSLIH
PRIVLULHH
CRLVPUFHD

Test 8

Verdict: ACCEPTED

input
ZDYIAVTKL
ZJKVXGAUM

correct output
ZDYIAVTKL
ZJYVAGTUL
ZJKVXGAUM

user output
ZDYIAVTKL
ZDKIXVAKM
ZJKVXGAUM

Test 9

Verdict:

input
FBIXISJH
NXZIESMG

correct output
FBIXISJH
NBZXESMH
NXZIESMG

user output
FBIXISJH
FXIIISJG
NXZIESMG

Test 10

Verdict: ACCEPTED

input
OPGW
QJIE

correct output
OPGW
QPIW
QJIE

user output
OPGW
QPIW
QJIE

Test 11

Verdict:

input
DUKNPKQZBL
NZPBMOEBIC

correct output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

user output
DUKNPKQZBL
DZKBPOQBBC
NZPBMOEBIC

Test 12

Verdict:

input
ZWDTX
HZOXI

correct output
ZWDTX
HWOTI
HZOXI

user output
ZWDTX
ZZDXX
HZOXI

Test 13

Verdict: ACCEPTED

input
URJF
ITIQ

correct output
URJF
IRIF
ITIQ

user output
URJF
IRIF
ITIQ

Test 14

Verdict:

input
WYWBWU
IRYVBA

correct output
WYWBWU
WRWVWA
IRYVBA

user output
WYWBWU
IYYBBU
IRYVBA