# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1035716 | why_5_mins | 미술 수업 (IOI13_artclass) | C++14 | 55 ms | 22460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;
int HH,WW;
int const_dif_lejer = 50;
int const_dif_hard = 20;
int RR[505][505],GG[505][505],BB[505][505];
bool similar(int r1, int g1, int b1, int r2, int g2, int b2, int const_dif)
{
if (abs(r1 - r2) > const_dif or abs(g1 - g2) > const_dif or abs(b1 - b2) > const_dif)
return false;
return true;
}
bool sim(int l1, int c1, int l2, int c2)
{
return similar(RR[l1][c1], GG[l1][c1], BB[l1][c1], RR[l2][c2], GG[l2][c2], BB[l2][c2], const_dif_lejer);
}
int dl[] = {-1,0,1,0};
int dc[] = {0,1,0,-1};
bool viz[505][505];
void dfs(int lin, int col)
{
viz[lin][col] = true;
for (int i = 0; i < 4; i++)
{
int nl = lin + dl[i],nc = col + dc[i];
if (nl >= 0 and nl < HH and nc >= 0 and nc < WW and sim(lin,col,nl,nc) and !viz[nl][nc])
dfs(nl,nc);
}
}
bool stil_4()
{
for (int i = 0; i < HH; i++)
for (int j = 0; j < WW; j++)
viz[i][j] = false;
int cc = 0;
for (int i = 0; i < HH; i++)
for (int j = 0; j < WW; j++)
if (!viz[i][j])
cc++,dfs(i,j);
if (cc <= 25)
return true;
return false;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
HH = H;
WW = W;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
RR[i][j] = R[i][j],GG[i][j] = G[i][j],BB[i][j] = B[i][j];
vector<bool> could_be(5);
for (int i = 1; i <= 4; i++)
could_be[i] = true;
int cnt_nonculoare = 0,cnt_alb = 0,cnt_negru = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
if (similar(R[i][j],G[i][j],B[i][j],0,0,0,const_dif_lejer))
cnt_negru++;
if (similar(R[i][j],G[i][j],B[i][j],255,255,255,const_dif_lejer))
cnt_alb++;
}
}
cnt_nonculoare = cnt_alb + cnt_negru;
double proc_alb = (double)cnt_alb / (double)(H * W);
double proc_negru = (double)cnt_negru / (double)(H * W);
double proc_nonculoare = (double)cnt_nonculoare / (double)(H * W);
int sum_R = 0, sum_G = 0, sum_B = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
sum_R += R[i][j];
sum_G += G[i][j];
sum_B += B[i][j];
}
}
double proc_R = (double)sum_R / (double)(sum_R + sum_G + sum_B);
double proc_G = (double)sum_G / (double)(sum_R + sum_G + sum_B);
double proc_B = (double)sum_G / (double)(sum_R + sum_G + sum_B);
int cate_dom_G = 0,cate_dom_R = 0, cate_dom_B = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
int r = R[i][j] - 20,g = G[i][j],b = B[i][j];
if (g > max(r,b) + 10)
cate_dom_G++;
if (r > max(g,b) + 10)
cate_dom_R++;
if (b > max(g,r) + 10)
cate_dom_B++;
}
}
double proc_dom_G = 0,proc_dom_R = 0,proc_dom_B = 0;
int sm_dom = cate_dom_R + cate_dom_G + cate_dom_B;
if (sm_dom != 0)
{
proc_dom_G = (double)cate_dom_G / (double)sm_dom;
proc_dom_R = (double)cate_dom_R / (double)sm_dom;
proc_dom_B = (double)cate_dom_B / (double)sm_dom;
}
//cout << setprecision(10) << fixed;
//cout << proc_dom_R << ' ' << proc_dom_G << ' ' << proc_dom_B << endl;
if (proc_alb >= 0.2d)
return 1;
if (stil_4())
return 4;
if (proc_negru >= 0.2d)
return 3;
return 2;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |