제출 #935119

#제출 시각아이디문제언어결과실행 시간메모리
935119antonArt Class (IOI13_artclass)C++17
8 / 100
63 ms6500 KiB
#include "artclass.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> struct pixel{ pixel(){ } int r, g, b; pixel(int a, int _b, int c){ r=a; g=_b; b=c; } void add(pixel& rh){ r += rh.r; b+=rh.b; g+=rh.g; } void round_pixel(int rond){ r =(r/rond)*rond; g =(g/rond)*rond; b =(b/rond)*rond; } string to_s(){ string res; res.push_back(r); res.push_back(g); res.push_back(b); return res; } }; const int comp = 20; pixel img[500][500]; pixel img2[50][50]; int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { unordered_map<string, int> m; for(int i = 0; i<H; i++){ for(int j = 0; j<W; j++){ img[i][j] = pixel(R[i][j], G[i][j], B[i][j]); img[i][j].round_pixel(40); img2[i/comp][j/comp].add(img[i][j]); //cout<<i/comp<<" "<<j/comp<<endl; m[img[i][j].to_s()]++; } } for(int i = 0; i<H/comp; i++){ for(int j = 0; j<W/comp; j++){ //cout<<i<<" "<<j<<endl; //cout<<img2[i][j].r<<" "<<img2[i][j].g<<" "<<img2[i][j].b<<endl; int h_left= min(comp, H-(i*comp)); int w_left= min(comp, W-(j*comp)); img2[i][j].r/=(h_left*w_left); img2[i][j].g/=(h_left*w_left); img2[i][j].b/=(h_left*w_left); //cout<<img2[i][j].r<<" "<<img2[i][j].g<<" "<<img2[i][j].b<<endl; } } vector<int> v; for(auto e: m){ v.push_back(e.second); } sort(v.begin(), v.end()); int mx=0; for(int i = 0; i<3; i++){ mx+= v[v.size()-1-i]; } double percentage = (double)(mx)/(double)(H*W); unordered_map<string, int> m2; for(int i = 0; i<H/comp; i++){ for(int j = 0; j<W/comp; j++){ img2[i][j].round_pixel(50); m2[img2[i][j].to_s()]++; } } vector<int> v2; for(auto e: m2){ v2.push_back(e.second); } sort(v2.begin(), v2.end()); int mx2=0; for(int i = 0; i<1; i++){ mx2+= v2[v2.size()-1-i]; } double percentage2 = (double)(mx2)/(double)((H/comp)*(W/comp)); //cout<<v.size()<<endl; //cout<<percentage<<" "<<percentage2<<endl; if(percentage>0.5){ if(percentage2 >0.4){ return 4; } else{ return 1; } } else{ if(percentage2 >0.4){ return 3; } else{ return 2; } } /*ll s= 0.; for(int j = 0; j<W; j++){ for(int i = 0; i<H-1; i++){ s+=(R[j][i+1]-R[j][i])*(R[j][i+1]-R[j][i]) + (G[j][i+1]-G[j][i])*(G[j][i+1]-G[j][i]) + (B[j][i+1]-B[j][i])*(B[j][i+1]-B[j][i]); } } double avg = (double)(s)/((double)((H-1)*W)); cout<<avg<<endl;*/ }
#Verdict Execution timeMemoryGrader output
Fetching results...