CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Babaza Game
Sender:user1111
Submission time:2024-09-02 17:57:46 +0300
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails

Compiler report

input/code.cpp: In function 'bool babaza(std::string)':
input/code.cpp:5:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |     for (int i = 0; i < a.length()-1; i++) {
      |                     ~~^~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < a.length(); i++) {
      |                     ~~^~~~~~~~~~~~
input/code.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i = 0; i < a.length(); i++) {
      |                     ~~^~~~~~~~~~~~
input/code.cpp:56:23: warning: comparison of integ...

Code

#include <bits/stdc++.h>
using namespace std;
 
bool babaza(string a) {
    for (int 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 (int i = 0; i < a.length(); i++) {
        if (b[i] != a[i]) absdiff[i] = '0';
        if (i%2) {
            ldiff[i] = b[i];
        } else {
            rdiff[i] = b[i];
        }
    }
    if (babaza(absdiff)) {
        cout << a << '\n';
        cout << b << '\n';
        return 0;
    }
 
    if (babaza(ldiff)) {
        cout << a << '\n';
        cout << ldiff << '\n';
        cout << b << '\n';
        return 0; 
    }
    if (babaza(rdiff)) {
        cout << a << '\n';
        cout << rdiff << '\n';
        cout << b << '\n';
        return 0; 
    }
 
    set<char> used = {};
    for (int 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 (int i = 0; i < a.length(); i++) {
        if (i%2) {
            ldiff[i] = unused;
        }
    }
    cout << ldiff << '\n';
    for (int 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: ACCEPTED

input
BABAZA
BACBCB

correct output
BABAZA
BACACA
BACBCB

user output
BABAZA
BACACA
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: ACCEPTED

input
AXYB
CXYD

correct output
AXYB
CXYD

user output
AXYB
CXYD

Test 6

Verdict: ACCEPTED

input
LMIJLF
PAQBMH

correct output
LMIJLF
PMQJMF
PAQBMH

user output
LMIJLF
LAIBLH
PAQBMH

Test 7

Verdict: ACCEPTED

input
PNIWLSLIH
CRLVPUFHD

correct output
PNIWLSLIH
CNLWPSFID
CRLVPUFHD

user output
PNIWLSLIH
CNLWPSFID
CRLVPUFHD

Test 8

Verdict: ACCEPTED

input
ZDYIAVTKL
ZJKVXGAUM

correct output
ZDYIAVTKL
ZJYVAGTUL
ZJKVXGAUM

user output
ZDYIAVTKL
ZJYVAGTUL
ZJKVXGAUM

Test 9

Verdict: ACCEPTED

input
FBIXISJH
NXZIESMG

correct output
FBIXISJH
NBZXESMH
NXZIESMG

user output
FBIXISJH
NBZXESMH
NXZIESMG

Test 10

Verdict: ACCEPTED

input
OPGW
QJIE

correct output
OPGW
QPIW
QJIE

user output
OPGW
OJGE
QJIE

Test 11

Verdict: ACCEPTED

input
DUKNPKQZBL
NZPBMOEBIC

correct output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

user output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

Test 12

Verdict: ACCEPTED

input
ZWDTX
HZOXI

correct output
ZWDTX
HWOTI
HZOXI

user output
ZWDTX
HWOTI
HZOXI

Test 13

Verdict: ACCEPTED

input
URJF
ITIQ

correct output
URJF
IRIF
ITIQ

user output
URJF
UTJQ
ITIQ

Test 14

Verdict: ACCEPTED

input
WYWBWU
IRYVBA

correct output
WYWBWU
WRWVWA
IRYVBA

user output
WYWBWU
WRWVWA
IRYVBA