Submission #1155624

#TimeUsernameProblemLanguageResultExecution timeMemory
1155624alexddArt Class (IOI13_artclass)C++20
100 / 100
36 ms6324 KiB
#include "artclass.h" #include<bits/stdc++.h> using namespace std; int dx[4] = {-1,1,0,0}; int dy[4] = {0,0,-1,1}; int H,W; int R[505][505],G[505][505],B[505][505]; bool is_green() { int cnt=0; for(int i=1;i<=H;i++) { for(int j=1;j<=W;j++) { //if(G[i][j] >= max(R[i][j], B[i][j])) cnt++; if(2*G[i][j] >= R[i][j] + B[i][j]) cnt++; } } if(cnt*8 >= H*W*7) return 1; return 0; } bool visited[505][505]; int DIFF = 30; bool similar(int ax, int ay, int bx, int by) { if(abs(R[ax][ay]-R[bx][by]) + abs(G[ax][ay]-G[bx][by]) + abs(B[ax][ay]-B[bx][by]) <= DIFF) return 1; return 0; } int sum_vec_dif() { int sum=0,cnt=0; for(int i=1;i<=H;i++) { for(int j=1;j<=W;j++) { if(i+1<=H) cnt++,sum+=abs(R[i][j]-R[i+1][j]) + abs(G[i][j]-G[i+1][j]) + abs(B[i][j]-B[i+1][j]); if(j+1<=W && !similar(i,j,i,j+1)) cnt++,sum+=abs(R[i][j]-R[i][j+1]) + abs(G[i][j]-G[i][j+1]) + abs(B[i][j]-B[i][j+1]); } } return sum / cnt; } int style(int cit_H, int cit_W, int cit_R[500][500], int cit_G[500][500], int cit_B[500][500]) { H = cit_H; W = cit_W; for(int i=1;i<=H;i++) { for(int j=1;j<=W;j++) { R[i][j] = cit_R[i-1][j-1]; G[i][j] = cit_G[i-1][j-1]; B[i][j] = cit_B[i-1][j-1]; } } //if(is_green()) return 2; int x = sum_vec_dif(); if(x <= 12) return 4; if(x <= 35) return 1; if(x >= 75) return 3; return 2; /*if(is_green()) return 2; if(nr_zones(50) <= 100) return 4; if(nr_vec_dif(50) <= 5000) return 4; if(nr_zones(5)*3 >= H*W *2) return 3;*/ return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...