Submission details
Task:Maalaus
Sender:nikke5
Submission time:2025-11-07 15:22:35 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

Output limit exceeded in compilation

Code

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <chrono>
#include <iomanip>

typedef long long ll;
using namespace std;

struct row
{
    int color = 0;
    int x = -1;
    int y = -1;
};

row rivit[200000];

int main()
{


    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int height, width, colorAmount, operationAmount;

    cin >> height >> width >> colorAmount >> operationAmount;

    auto start = chrono::high_resolution_clock::now();

    int columnAmount = 0;
    int rowAmount = 0;

    vector<ll> colorResults(colorAmount + 1);

    for (int i = 0; i < operationAmount; i++)
    {
        string operation;
        int location, color;
        cin >> operation >> location >> color;
        location--;

        if (operation == "R")
        {

            bool dupeFound = false;

            for (int c = 0; c < i; c++)
            {
                if (rivit[c].y == location)
                {
                    rivit[c].y = -1;
                    dupeFound = true;
                    break;
                }
            }

            row rivi;
            rivi.color = color;
            rivi.y = location;
            rivit[i] = rivi;

            if (!dupeFound)
                rowAmount++;
        }
        if (operation == "C")
        {
            bool dupeFound = false;

            for (int c = 0; c < i; c++)
            {
                if (rivit[c].x == location)
                {
                    rivit[c].x = -1;
                    dupeFound = true;
                    break;
                }
            }

            row sarake;
            sarake.color = color;
            sarake.x = location;
            rivit[i] = sarake;

            if (!dupeFound)
                columnAmount++;
        }
    }

    int currentRowsUnder = 0;
    int currentColumsUnder = 0;

    // lasku
    for (int i = 0; i < operationAmount; i++)
    {
        if (rivit[i].x == -1 && rivit[i].y != -1)
        {
            //cout << currentColumsUnder << " rivi " << rivit[i].color << "\n";
            // lisätään kaikki rivit, miinustetaan kaikki täydet poikkirivit ja lisätään takaisin ne kohdat joissa tämä rivi on poikkirivin yläpuolella
            colorResults[rivit[i].color] += width - columnAmount + currentColumsUnder;

            currentRowsUnder++;
        }
        if (rivit[i].y == -1 && rivit[i].x != -1)
        {
            //cout << currentRowsUnder << " sarake " << rivit[i].color << "\n";
            // lisätään kaikki rivit, miinustetaan kaikki täydet poikkirivit ja lisätään takaisin ne kohdat joissa tämä rivi on poikkirivin yläpuolella
            colorResults[rivit[i].color] += height - rowAmount + currentRowsUnder;

            currentColumsUnder++;
        }
    }

    for (int i = 1; i <= colorAmount; i++)
    {
        cout << colorResults[i] << " ";
    }

    auto stop = chrono::high_resolution_clock::now();

    auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
    cout << endl << duration.count() << endl;
}