Submission #962318

# Submission time Handle Problem Language Result Execution time Memory
962318 2024-04-13T10:32:42 Z serkanrashid Art Class (IOI13_artclass) C++14
Compilation error
0 ms 0 KB
#include "artclass.h"
#include <bits/stdc++.h>

using namespace std;

int h,w;

struct Point
{
    int x,y;
    Point(){};
    Point(int xi, int yi)
    {
        x = xi;
        y = yi;
    }
    bool is_valid()
    {
        return x>=0&&x<h&&y>=0&&y<w;
    }
};

Point dir[4] = {{1,0},{-1,0},{0,1},{0,-1}};
int r[500][500],g[500][500],b[500][500];
int c[500][500],used[500][500];

vector<int>comp;
map<int,int>mymap;

void dfs(Point beg)
{
    used[beg.x][beg.y] = 1;
    for(int i = 0; i < 4; i++)
    {
        Point nb;
        nb.x = w.x + dir[i].x;
        nb.y = w.y + dir[i].y;
        if(nb.is_valid() && !used[nb.x][nb.y]) dfs(nb);
    }
}

int col_br;
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
    h = H;
    w = W;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            r[i][j] = R[i][j]/10;
            g[i][j] = G[i][j]/10;
            b[i][j] = B[i][j]/10;
            c[i][j] = r[i][j]*10000 + g[i][j]*100 + b[i][j];
        }
    }
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            if(!used[i][j])
            {
                dfs({i,j});
                comp.push_back(c[i][j]);
                mymap[c[i][j]]++;
                if(mymap[c[i][j]]==1) col_br++;
            }
        }
    }
    if(col_br<=4&&comp.size()<=5) return 4;
    if(col_br<=7&&comp.size()<=30) return 1;
    if(col_br>=50&&comp.size()>=200) return 2;
    return 3;
}

Compilation message

artclass.cpp: In function 'void dfs(Point)':
artclass.cpp:36:18: error: request for member 'x' in 'w', which is of non-class type 'int'
   36 |         nb.x = w.x + dir[i].x;
      |                  ^
artclass.cpp:37:18: error: request for member 'y' in 'w', which is of non-class type 'int'
   37 |         nb.y = w.y + dir[i].y;
      |                  ^