Submission #680229

#TimeUsernameProblemLanguageResultExecution timeMemory
680229Dan4LifeArt Class (IOI13_artclass)C++17
1 / 100
62 ms3324 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int avg(int a[][500], int y1=0, int x1=0, int y2=500, int x2=500){ int tot = 0; for(int i = y1; i < y2; i++) for(int j = x1; j < x2; j++) tot+=a[i][j]; return tot/((x2-x1+1)*(y2-y1+1)); } int cnt(int a[][500], int b[][500], int c[][500], int thl=0, int thr=255, int y1=0, int x1=0, int y2=500, int x2=500){ int tot = 0, x; for(int i = y1; i < y2; i++) for(int j = x1; j < x2; j++) x = (a[i][j]+b[i][j]+c[i][j])/3, tot+=(x>=thl and x<=thr); return tot; } int cnt(int a[][500], int thl=0, int thr=255, int y1=0, int x1=0, int y2=500, int x2=500){ int tot = 0; for(int i = y1; i < y2; i++) for(int j = x1; j < x2; j++) tot+=(a[i][j]>=thl and a[i][j]<=thr); return tot; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { int r = avg(R), g = avg(G), b = avg(B); int th = 125, nth = 500*500/3, nth2 = 430*420; if(r>=230 and g>=230 and b>=230) return 1; // lighter in general if(cnt(R,G,B,230,255) >= nth) return 1; // lots of light pixels if(avg(G,150)>=th and avg(B,150)<=40 and avg(R,150)<=100) return 2; if(r>=th and g>=th/2 and b<th) return 3; //average color is close to brown? idk if(cnt(B,50,170)>=nth2) return 4; if((r+g+b)/3>=th) return 4; return rand()%4+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...