CSES - Datatähti 2025 alku - Results
Submission details
Task:Niitty
Sender:nikke5
Submission time:2024-11-05 19:16:07 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
#60
Test results
testverdicttimegroup
#10.99 s1, 2, 3, 4, 5, 6details
#2--1, 2, 3, 4, 5, 6details
#30.00 s1, 2, 3, 4, 5, 6details
#40.00 s1, 2, 3, 4, 5, 6details
#5ACCEPTED0.00 s1, 2, 3, 4, 5, 6details
#6--2, 3, 4, 5, 6details
#7--2, 3, 4, 5, 6details
#80.01 s2, 3, 4, 5, 6details
#90.41 s2, 3, 4, 5, 6details
#100.00 s3, 4, 5, 6details
#11--3, 4, 5, 6details
#120.00 s3, 4, 5, 6details
#130.00 s3, 4, 5, 6details
#140.00 s4, 5, 6details
#150.00 s4, 5, 6details
#160.00 s4, 5, 6details
#17--4, 5, 6details
#180.00 s5, 6details
#190.00 s5, 6details
#200.00 s5, 6details
#210.00 s5, 6details
#220.00 s6details
#230.00 s6details
#240.00 s6details
#250.00 s6details

Compiler report

input/code.cpp: In function 'void createRects(int)':
input/code.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<flower> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     if (level == flist.size()){
      |         ~~~~~~^~~~~~~~~~~~~~~
input/code.cpp:74:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<flower>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |     for (int i = 0; i<flist[level].size(); i++){ // LOOP THE CURRENT LEVEL (FLOWER TYPE)
      |                     ~^~~~~~~~~~~~~~~~~~~~

Code

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

typedef long long ll;
using namespace std;

struct flower{

    int x, y;

    int id;
    int listIt;

    
    char idC; //Remove later, its just to visualize


    
};

vector<vector<flower>> flist;

//cout << flist[0][i].x << ", " << flist[0][i].y << ", " << flist[0][i].idC << ", " << distLists[0][0][i].first << ", " << distLists[0][1][i].first << "\n";

int idList[200] = {0};

vector<vector<int>> rectList; 

vector<int> currentX, currentY;

void findSmallestRect(vector<int> X, vector<int> Y, int p[]) 
{ 
    // find Xmax and Xmin 
    int Xmax = *max_element(X.begin(), X.end()); 
    int Xmin = *min_element(X.begin(), X.end()); 
  
    // find Ymax and Ymin 
    int Ymax = *max_element(Y.begin(), Y.end()); 
    int Ymin = *min_element(Y.begin(), Y.end()); 
  
    // print all four coordinates 
    p[0] = Xmax;
    p[1] = Xmin;
    p[2] = Ymax;
    p[3] = Ymin;
} 

void createRects(int level){

    if (level == flist.size()){
        int EndCoords[4]; // Pienimmän mahdollisen suorakulmion koordinaatit järjestyksessä; XMax, Xmin, Ymax, Ymin.

        findSmallestRect(currentX, currentY, EndCoords);

        rectList.push_back(vector<int>());

        for (int i = 0; i < 4; i++)
        {
            rectList[rectList.size()-1].push_back(EndCoords[i]);
        }

        // cout << rectList[rectList.size() - 1][0] << ", " << rectList[rectList.size() - 1][1] << ", " << rectList[rectList.size() - 1][2] << ", " << rectList[rectList.size() - 1][3] << "\n";
        // cout << "\n";
        return;
    }

    for (int i = 0; i<flist[level].size(); i++){ // LOOP THE CURRENT LEVEL (FLOWER TYPE)
        currentX.push_back(flist[level][i].x);
        currentY.push_back(flist[level][i].y);

        // cout << flist[level][i].idC << ", ";

        createRects(level + 1);

        currentX.pop_back();
        currentY.pop_back();
    }

}


int main(){

    fill_n(idList, 200, -1);

    int n;

    cin >> n;
    // cin.ignore(1,'\n');

    int id = 0;

    for (int y = n-1; y>=0; y--){

        string s;
        getline(cin, s);

        for (int x = 0; x<n; x++){
            flower f;
            f.x = x;
            f.y = y;
            f.idC = s[x];

            if (idList[(int)s[x]] == -1){
                idList[(int)s[x]] = id;
                flist.push_back(vector<flower>());
                id++;
            }

            
            f.id = idList[(int)s[x]];

            f.listIt = flist[f.id].size();
            flist[f.id].push_back(f);

        }
    }

    sort(flist.begin(), flist.end(), [](const vector<flower> & a, const vector<flower> & b){ return a.size() < b.size(); }); // JÄRJESTÄ LISTA HARVINAISIMMASTA YLEISIMPÄÄN

    
    createRects(0);



    sort(rectList.begin(), rectList.end());

    auto it
        = unique(rectList.begin(), rectList.end());


    rectList.erase(it, rectList.end());

    // cout << "\n ----------------- \n";

    // for (int i = 0; i<rectList.size(); i++){
    //     for (int j = 0; j < 4; j++)
    //     {
    //         cout << rectList[i][j] << ", ";
    //     }
    //     cout << "\n";
    // }

    cout << rectList.size();


}

Test details

Test 1

Group: 1, 2, 3, 4, 5, 6

Verdict:

input
10
TNCTNPNTPC
NPPNTNTPTP
NTNTTCNTCT
NPCPNPPNTT
...

correct output
2035

user output
106

Test 2

Group: 1, 2, 3, 4, 5, 6

Verdict:

input
10
NFWQLWNWYS
DZOQJVXFPJ
CNHXPXMCQD
QRTBVNLTQC
...

correct output
9

user output
(empty)

Test 3

Group: 1, 2, 3, 4, 5, 6

Verdict:

input
10
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
...

correct output
3025

user output
108

Test 4

Group: 1, 2, 3, 4, 5, 6

Verdict:

input
10
FFFFFFFFFF
FFFFFCFFFF
FFFFFFJFFF
FFFFFFFFFF
...

correct output
12

user output
2

Test 5

Group: 1, 2, 3, 4, 5, 6

Verdict: ACCEPTED

input
1
X

correct output
1

user output
1

Test 6

Group: 2, 3, 4, 5, 6

Verdict:

input
20
BBCBUBOUOBBCUUBBCOUO
BOUCOOCUBCOOOCOBOCUO
UCCUUUOBCOCBCBUBUCOO
BUOBUCUCUOOBCOOUBUOO
...

correct output
38724

user output
(empty)

Test 7

Group: 2, 3, 4, 5, 6

Verdict:

input
20
CBGLSHGZHYZDWBNDBJUG
SMUXOJQYPXZDTMJUIWOJ
XIDSTNBGHKRKOVUVMINB
MTQGCFRUHQKALXRNCQGS
...

correct output
8334

user output
(empty)

Test 8

Group: 2, 3, 4, 5, 6

Verdict:

input
20
KKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKK
...

correct output
44100

user output
76

Test 9

Group: 2, 3, 4, 5, 6

Verdict:

input
20
AAAAAAAAXAAAAAAAAAAA
AAAWAAAAAAAAAAAAAOAA
AAAAAAAAAAAAAAAAAPAA
AAAAAAAAKAAAAAAAAAAZ
...

correct output
18

user output
4

Test 10

Group: 3, 4, 5, 6

Verdict:

input
50
GRGREEEGREGXRXXEGXXREXGRRRGRRR...

correct output
1584665

user output
(empty)

Test 11

Group: 3, 4, 5, 6

Verdict:

input
50
AITIISJUHCCRZNKSDCNQKYSQRINFWJ...

correct output
1077746

user output
(empty)

Test 12

Group: 3, 4, 5, 6

Verdict:

input
50
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO...

correct output
1625625

user output
(empty)

Test 13

Group: 3, 4, 5, 6

Verdict:

input
50
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF...

correct output
1680

user output
(empty)

Test 14

Group: 4, 5, 6

Verdict:

input
100
NNCMDCDDCCNNNDNCMMNCDCDCCDCDNM...

correct output
25325366

user output
(empty)

Test 15

Group: 4, 5, 6

Verdict:

input
100
LIMQQIHASECROEVILNVULGWZJPPKOG...

correct output
22342463

user output
(empty)

Test 16

Group: 4, 5, 6

Verdict:

input
100
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

correct output
25502500

user output
(empty)

Test 17

Group: 4, 5, 6

Verdict:

input
100
QXQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
25650

user output
(empty)

Test 18

Group: 5, 6

Verdict:

input
200
NAANANMMKNKKAKMKMAKNKMNKMMNNAA...

correct output
403292767

user output
(empty)

Test 19

Group: 5, 6

Verdict:

input
200
OMYWATTLURKQPTKEFMGGYAOONXWVSC...

correct output
388111321

user output
(empty)

Test 20

Group: 5, 6

Verdict:

input
200
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

correct output
404010000

user output
(empty)

Test 21

Group: 5, 6

Verdict:

input
200
LLLLLLLLLLLLLLLLLHLLLLLLLLLLLL...

correct output
14159445

user output
(empty)

Test 22

Group: 6

Verdict:

input
500
VVHWVUHVHUWWWVUUUWVUUHUUWHWUVW...

correct output
15683003812

user output
(empty)

Test 23

Group: 6

Verdict:

input
500
OIMZGEQSBMBDSDXSWRFNKSGFEBBTJE...

correct output
15575906951

user output
(empty)

Test 24

Group: 6

Verdict:

input
500
IIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

correct output
15687562500

user output
(empty)

Test 25

Group: 6

Verdict:

input
500
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW...

correct output
3058970930

user output
(empty)