Submission #1303530

#TimeUsernameProblemLanguageResultExecution timeMemory
1303530activedeltorreArt Class (IOI13_artclass)C++20
43 / 100
50 ms38916 KiB
#include "artclass.h"
#include <iostream>
#include <iomanip>
using namespace std;
pair<int,int> sef[505][505][10];
int sz[505][505][10];
int trd=9;
int v[]= {1,2,3,5,10,20,30,35,50};
pair<int,int> find(pair<int,int> a,int tr)
{
    if(sef[a.first][a.second][tr]==a)
    {
        return a;
    }
    return sef[a.first][a.second][tr]=find(sef[a.first][a.second][tr],tr);
}
void merge(pair<int,int>a,pair<int,int>b,int tr)
{
    a=find(a,tr);
    b=find(b,tr);
    if(a==b)
    {
        return;
    }
    sef[b.first][b.second][tr]=a;
    sz[a.first][a.first][tr]+=sz[b.first][b.first][tr];
}
double r1[505][505];
double g1[505][505];
double b1[505][505];
long long tot=0,cnt=0,tot2=0,tot3=0;
long long tot0=0,cnt0=0,tot20=0,tot30=0;
void trysame(int a,int b,int x,int y)
{
    int val=abs(r1[a][b]-r1[x][y])+abs(b1[a][b]-b1[x][y])+abs(g1[a][b]-g1[x][y]);
    tot=tot+val;
    tot2=tot2+val*val;
    tot3=tot3+val*val*val;
    cnt++;
    if(val>=2)
    {
        tot0=tot0+val;
        tot20=tot20+val*val;
        tot30=tot30+val*val*val;
        cnt0++;
    }
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{

    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            for(int z=0; z<trd; z++)
            {
                sef[i][j][z]=make_pair(i,j);
                sz[i][j][z]=1;
            }
        }
    }
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            int sum=R[i][j]+G[i][j]+B[i][j]+1;
            r1[i][j]=R[i][j]*100.0/sum;
            g1[i][j]=G[i][j]*100.0/sum;
            b1[i][j]=B[i][j]*100.0/sum;
            if(i>=1)
            {
                trysame(i,j,i-1,j);
            }
            if(j>=1)
            {
                trysame(i,j,i,j-1);
            }
        }
    }
    /*
    for(int z=0; z<trd; z++)
    {
        int comps=0;
        for(int i=0; i<H; i++)
        {
            for(int j=0; j<W; j++)
            {
                if(sef[i][j][z].first==i && sef[i][j][z].second==j)
                {
                    comps++;
                }
            }
        }
        cout<<z<<" "<<v[z]<<"% "<<comps<<'\n';
    }

    */
    /*
    cout<<fixed<<setprecision(6)<<" "<<(double)tot/cnt;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot2/cnt;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot3/cnt;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot2/tot;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot3/tot2;
    cout<<fixed<<setprecision(6)<<"    "<<(double)tot0/cnt0;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot20/cnt0;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot30/cnt0;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot20/tot0;
    cout<<fixed<<setprecision(6)<<" "<<(double)tot30/tot20;*/
    if(cnt0==0)
    {
        cnt0=1;
    }
    if(cnt==0)
    {
        cnt=1;
    }
    cout<<'\n';
    if((double)tot/cnt<=2.3 && (double)tot2/tot<=11)
    {
        return 4;
    }
    if((double)tot/cnt>5.7)
    {
        return 3;
    }
    if((double)tot0/cnt0>=9)
    {
        return 1;
    }
    if((double)tot/cnt>=3.4)
    {
        return 2;
    }
    return 3;
    /*
    */
}
#Verdict Execution timeMemoryGrader output
Fetching results...