CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Babaza Game
Sender:bielaltes
Submission time:2024-09-02 17:49:51 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#10.67 sdetails
#20.80 sdetails
#30.76 sdetails
#40.77 sdetails
#50.78 sdetails
#60.80 sdetails
#70.84 sdetails
#80.84 sdetails
#90.82 sdetails
#100.78 sdetails
#110.86 sdetails
#120.78 sdetails
#130.79 sdetails
#140.80 sdetails

Compiler report

input/code.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > change(std::string, std::string, int)':
input/code.cpp:16:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for (int i = 0; i < aux.size(); ++i){
      |                         ~~^~~~~~~~~~~~
input/code.cpp:19:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |                 if (i > 0 && aux[i-1] != desired && i < aux.size()-1 && aux[i+1] != desired)
      |                                                     ~~^~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:38:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'}...

Code

using namespace std;
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>

vector<string> change(string a, string b, int n){
    
    string aux = a;
    vector<string> res;
    res.push_back(a);
    while (res.back() != b){
        for (int i = 0; i < aux.size(); ++i){
            if (i % 2 == n % 2){
                char desired = b[i];
                if (i > 0 && aux[i-1] != desired && i < aux.size()-1 && aux[i+1] != desired)
                    aux[i] = desired;
            }
        }
        res.push_back(aux);
        ++n;
    }
    return res;
}

int main() {
    string a, b;

    cin >> a >> b;

    vector<string> v1 =  change(a, b, 0);
    vector<string> v2 = change(a, b, 1);

    if (v1.size() < v2.size()){
        for (int i = 0; i< v1.size(); ++i)
            cout << v1[i] << endl;
    }
    else{
        for (int i = 0; i< v2.size(); ++i)
            cout << v2[i] << endl;
    }


}

Test details

Test 1

Verdict:

input
A
B

correct output
A
B

user output
(empty)

Test 2

Verdict:

input
BABAZA
BACBCB

correct output
BABAZA
BACACA
BACBCB

user output
(empty)

Test 3

Verdict:

input
AB
BA

correct output
AB
CB
CA
BA

user output
(empty)

Test 4

Verdict:

input
ABC
BCD

correct output
ABC
DBD
DCD
BCD

user output
(empty)

Test 5

Verdict:

input
AXYB
CXYD

correct output
AXYB
CXYD

user output
(empty)

Test 6

Verdict:

input
LMIJLF
PAQBMH

correct output
LMIJLF
PMQJMF
PAQBMH

user output
(empty)

Test 7

Verdict:

input
PNIWLSLIH
CRLVPUFHD

correct output
PNIWLSLIH
CNLWPSFID
CRLVPUFHD

user output
(empty)

Test 8

Verdict:

input
ZDYIAVTKL
ZJKVXGAUM

correct output
ZDYIAVTKL
ZJYVAGTUL
ZJKVXGAUM

user output
(empty)

Test 9

Verdict:

input
FBIXISJH
NXZIESMG

correct output
FBIXISJH
NBZXESMH
NXZIESMG

user output
(empty)

Test 10

Verdict:

input
OPGW
QJIE

correct output
OPGW
QPIW
QJIE

user output
(empty)

Test 11

Verdict:

input
DUKNPKQZBL
NZPBMOEBIC

correct output
DUKNPKQZBL
NUPNMKEZIL
NZPBMOEBIC

user output
(empty)

Test 12

Verdict:

input
ZWDTX
HZOXI

correct output
ZWDTX
HWOTI
HZOXI

user output
(empty)

Test 13

Verdict:

input
URJF
ITIQ

correct output
URJF
IRIF
ITIQ

user output
(empty)

Test 14

Verdict:

input
WYWBWU
IRYVBA

correct output
WYWBWU
WRWVWA
IRYVBA

user output
(empty)