Submission #1101007

#TimeUsernameProblemLanguageResultExecution timeMemory
1101007alexander707070Art Class (IOI13_artclass)C++14
76 / 100
68 ms27588 KiB
#include<bits/stdc++.h>
#include "artclass.h"

using namespace std;

int n,m;
int RR[500][500],GG[500][500],BB[500][500],cnt;

bool vis[500][500];

bool iswhite(int r,int g,int b){
    return r>=200 and g>=200 and b>=200;
}

int diff(int x,int y,int w,int z){
    return abs(RR[x][y]-RR[w][z]) + abs(GG[x][y]-GG[w][z]) + abs(BB[x][y]-BB[w][z]);
}

void dfs(int x,int y){
    vis[x][y]=true;
    cnt++;

    if(x>0 and !vis[x-1][y] and diff(x,y,x-1,y)<=30)dfs(x-1,y);
    if(y>0 and !vis[x][y-1] and diff(x,y,x,y-1)<=30)dfs(x,y-1);
    if(x<n-1 and !vis[x+1][y] and diff(x,y,x+1,y)<=30)dfs(x+1,y);
    if(y<m-1 and !vis[x][y+1] and diff(x,y,x,y+1)<=30)dfs(x,y+1);
}


int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {

    n=H; m=W;

    for(int i=0;i<500;i++){
        for(int f=0;f<500;f++){
            RR[i][f]=R[i][f];
            GG[i][f]=G[i][f];
            BB[i][f]=B[i][f];

            vis[i][f]=false;
        }
    }

    int br=0,maxcnt=0;
    long long dif=0;

    for(int i=0;i<H;i++){
        for(int f=0;f<W;f++){
            if(iswhite(RR[i][f],GG[i][f],BB[i][f]))br++;

            if(f<W-1)dif+=diff(i,f,i,f+1);

            if(!vis[i][f]){
                cnt=0; dfs(i,f);
                maxcnt=max(maxcnt,cnt);
            }
        }
    }

    if(dif>5500000 and maxcnt<15000)return 3;
    if(maxcnt>50000 and dif<2500000)return 4;
    if(br>=70000)return 1;
    return 2;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...