I did it

Revision en1, by OMGITSNANB, 2025-09-10 11:08:10

Hey, it's been a while since I last wrote, and I did it. I finished a DIV 3 A question. It was the easiest question in the whole round, but I still feel proud of myself. The question was Codeforces Round 1043 (Div. 3) 2132A - Homework. This is my code:

#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int testcases;
    cin >> testcases;
    for (int i = 1; i <= testcases; i++) {
        int centralLetterCount, addedLetterCount;
        string centralLetters, addedLetters, order;
        cin >> centralLetterCount >> centralLetters;
        cin >> addedLetterCount >> addedLetters;
        cin >> order;
        string finalResults=centralLetters;
        int index = 0;
        for (int j = 0; j < order.length(); j++) {
            if (order[j] == 'V') {
                finalResults = addedLetters[index] + finalResults;
                index += 1;
            } else if (order[j] == 'D') {
                finalResults += addedLetters[index];
                index += 1;
            } else if (index >= addedLetterCount) {
                cout << "Error: order length larger than added letters amount\n";
                break;
            } else {
                cout << "Error: unexpected character in order string\n";
                break;
            }
        }
 
        cout << finalResults << '\n';
    }
    return 0;
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English OMGITSNANB 2025-09-10 11:16:33 16
en1 English OMGITSNANB 2025-09-10 11:08:10 1414 Initial revision (published)