CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Babaza Game
Sender:user1111
Submission time:2024-09-02 17:49:22 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.00 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

bool babaza(string a) {
    for (unsigned i = 0; i < a.length()-1; i++) {
        if (a[i] == a[i+1]) return false;
    }
    return true;
}

int main() {
	string a,b;
    cin >> a >> b;
    
    string absdiff = a;
    string ldiff = a, rdiff = a;
    for (unsigned i = 0; i < a.length(); i++) {
        absdiff[i] = b[i] != a[i];
        if (i%2) {
            ldiff[i] = b[i];
        } else {
            rdiff[i] = b[i];
        }
    }
    if (babaza(absdiff)) {
        cout << a << '\n';
        cout << b << '\n';
        return 0;
    }

    if (ldiff == b) {
        cout << a << '\n';
        cout << ldiff << '\n';
        cout << b << '\n';
        return 0; 
    }
    if (rdiff == b) {
        cout << a << '\n';
        cout << rdiff << '\n';
        cout << b << '\n';
        return 0; 
    }

    set<char> used = {};
    for (unsigned i = 0; i < a.length(); i++) {
        used.insert(a[i]);
        used.insert(b[i]);
    }
    char unused = 'A';
    for (;;unused++) {
        if (!(used.contains(unused))) {
            break;
        }
    }
    cout << a << '\n';
    for (unsigned i = 0; i < a.length(); i++) {
        if (i%2) {
            ldiff[i] = unused;
        }
    }
    cout << ldiff << '\n';
    for (unsigned i = 0; i < a.length(); i++) {
        if (!(i%2)) {
            ldiff[i] = b[i];
        }
    }
    cout << ldiff << '\n';
    cout << b << '\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
BDBDZD
BDCDCD
BACBCB

Test 3

Verdict: ACCEPTED

input
AB
BA

correct output
AB
CB
CA
BA

user output
AB
AC
BC
BA

Test 4

Verdict: ACCEPTED

input
ABC
BCD

correct output
ABC
DBD
DCD
BCD

user output
ABC
AEC
BED
BCD

Test 5

Verdict:

input
AXYB
CXYD

correct output
AXYB
CXYD

user output
AXYB
AEYE
CEYE
CXYD

Test 6

Verdict:

input
LMIJLF
PAQBMH

correct output
LMIJLF
PMQJMF
PAQBMH

user output
LMIJLF
LCICLC
PCQCMC
PAQBMH

Test 7

Verdict:

input
PNIWLSLIH
CRLVPUFHD

correct output
PNIWLSLIH
CNLWPSFID
CRLVPUFHD

user output
PNIWLSLIH
PAIALALAH
CALAPAFAD
CRLVPUFHD

Test 8

Verdict:

input
ZDYIAVTKL
ZJKVXGAUM

correct output
ZDYIAVTKL
ZJYVAGTUL
ZJKVXGAUM

user output
ZDYIAVTKL
ZBYBABTBL
ZBKBXBABM
ZJKVXGAUM

Test 9

Verdict:

input
FBIXISJH
NXZIESMG

correct output
FBIXISJH
NBZXESMH
NXZIESMG

user output
FBIXISJH
FAIAIAJA
NAZAEAMA
NXZIESMG

Test 10

Verdict:

input
OPGW
QJIE

correct output
OPGW
QPIW
QJIE

user output
OPGW
OAGA
QAIA
QJIE

Test 11

Verdict:

input
DUKNPKQZBL
NZPBMOEBIC

correct output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

user output
DUKNPKQZBL
DAKAPAQABA
NAPAMAEAIA
NZPBMOEBIC

Test 12

Verdict:

input
ZWDTX
HZOXI

correct output
ZWDTX
HWOTI
HZOXI

user output
ZWDTX
ZADAX
HAOAI
HZOXI

Test 13

Verdict:

input
URJF
ITIQ

correct output
URJF
IRIF
ITIQ

user output
URJF
UAJA
IAIA
ITIQ

Test 14

Verdict:

input
WYWBWU
IRYVBA

correct output
WYWBWU
WRWVWA
IRYVBA

user output
WYWBWU
WCWCWC
ICYCBC
IRYVBA