Submission details
Task:Maalaus
Sender:rottis
Submission time:2025-10-28 00:00:43 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:81:50: error: expected primary-expression before ')' token
   81 |             if (/*existing_rows.count(idx) == 0*/) {
      |                                                  ^
input/code.cpp:91:50: error: expected primary-expression before ')' token
   91 |             if (/*existing_cols.count(idx) == 0*/) {
      |                                                  ^
input/code.cpp:74:15: warning: unused variable 'idx' [-Wunused-variable]
   74 |         ulong idx = indices[i];
      |               ^~~

Code

#include <iostream>
#include <vector>
#include <unordered_set>

enum RowType {
    ROW,
    COL
};

typedef unsigned long ulong;

typedef struct Operation {
    long idx;
    long time;
    long color;
} Operation;

/*
void print_op(std::vector<Operation> arr) {
    for (Operation cur : arr) {
        //std::cout << cur.idx << ' ' << cur.time << ' ' << cur.color << std::endl;
    }
}

void print_colors(ulong* colors, long size) {
    for (long i = 0; i < size; i++) {
        //std::cout << colors[i] << ' ';
    }
    //std::cout << std::endl;
}*/

ulong hgt, wid, color_count, operation_count;

int main() {
    long time = 0;
    std::vector<Operation> row_operations;
    std::vector<Operation> col_operations;

    ulong next_row_index = 0;
    ulong next_col_index = 0;
    std::unordered_set<ulong> existing_rows;
    std::unordered_set<ulong> existing_cols;

    std::cin >> hgt >> wid >> color_count >> operation_count;
    
    existing_rows.reserve(operation_count);
    existing_cols.reserve(operation_count);

    row_operations.reserve(operation_count);
    col_operations.reserve(operation_count);

    char rows[20001];
    ulong indices[20001];
    ulong colors[20001];
    /*std::cout << "before: " << std::endl;
    print_colors(colors, operation_count);*/
    for (ulong i = 0; i < operation_count; i++) {
        char c;
        ulong idx, color;
        
        std::cin >> c >> idx >> color;
        
        rows[i] = c;
        indices[i] = idx;
        colors[i] = color - 1;
    }
    /*std::cout << "after: " << std::endl;
    print_colors(colors, operation_count);
    std::cout << std::endl;*/

    char last_row = 'Z';
    for (long i = operation_count - 1; i >= 0; i--) {
        char row = rows[i];
        ulong idx = indices[i];
        long color = colors[i];
        //std::cout << "row: " << row << ", idx: " << idx << ", color: " << color << std::endl;

        if (row != last_row) { time++; }

        if (row == 'R') {
            if (/*existing_rows.count(idx) == 0*/) {
                //existing_rows.insert(idx);
                long translated_row = next_row_index++;
                //std::cout << "next_row_index: " << next_row_index << std::endl;
                row_operations.push_back({
                    translated_row, time, color
                });
            }

        } else {
            if (/*existing_cols.count(idx) == 0*/) {
                //existing_cols.insert(idx);
                long translated_col = next_col_index++;
                //std::cout << "next_col_index: " << next_col_index << std::endl;
                col_operations.push_back({
                    translated_col, time, color
                });
            }
        }

        last_row = row;
    }

    //print_op(row_operations);
    //print_op(col_operations);

    std::cout << "intentionally wrong answer" << std::endl;
    return 0;
    long rows_left_unmodified = hgt - next_row_index;
    //std::cout << "hgt: " << hgt << ", next_row_index: " << next_row_index << ", rows left unmodified: " << rows_left_unmodified << std::endl;
    long cols_left_unmodified = wid - next_col_index;
    //std::cout << "wid: " << wid << ", next_col_index: " << next_col_index << ", cols left unmodified: " << cols_left_unmodified << std::endl;

    ulong colors_sum[20001];
    for (long i = 0; i < 20000; i++) {
        colors_sum[i] = 0;
    }

    for (Operation operation: row_operations) {
        colors_sum[operation.color] += cols_left_unmodified;
    }

    for (Operation operation: col_operations) {
        colors_sum[operation.color] += rows_left_unmodified;
    }

    // Exceptions:
    // - no operations are defined
    // - only rows are given
    // - only cols are given
    // Ignore if exception moment
    if (next_col_index && next_row_index) {
        time = 0;
        RowType cur_type;
        long row_index = 0;
        long row_length = next_row_index - 1;
        long col_index = 0;
        long col_length = next_col_index - 1;

        if (row_operations[0].time < col_operations[0].time) {
            time = row_operations[row_index].time;
            cur_type = RowType::ROW;
        } else {
            time = col_operations[col_index].time;
            cur_type = RowType::COL;
        }

        while (row_length >= 0 && col_length >= 0) {
            if (cur_type == RowType::ROW) {
                Operation row = row_operations[row_index];
                //std::cout << "ROW " << row_index << ", color: " << row.color << ", time: " << time << ", rowtime: " << row.time << std::endl;
                
                if (time < row.time) { time++; cur_type = RowType::COL; continue; }

                //std::cout << "Add " << col_length + 1 << " to " << row.color << std::endl;
                colors_sum[row.color] += col_length + 1;
                
                row_index++;
                row_length--;
            } else {
                Operation col = col_operations[col_index];
                //std::cout << "COL " << col_index << ", color: " << col.color << ", time: " << time << ", rowtime: " << col.time << std::endl;
                
                if (time < col.time) { time++; cur_type = RowType::ROW; continue; }

                //std::cout << "Add " << row_length + 1 << " to " << col.color << std::endl;
                colors_sum[col.color] += row_length + 1;
                
                col_index++;
                col_length--;
            }
        }
    }
    

    // print
    for (ulong i = 0; i < color_count; i++) {
        std::cout << colors_sum[i] << ' ';
    }
    std::cout.flush();

    return 0;
}