# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
591834 | dnass | Art Class (IOI13_artclass) | C++17 | 128 ms | 9292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef long double lf;
int h, w;
int r[500][500], g[500][500], b[500][500];
lf calc_green(){
lld res = 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
res += (g[i][j]-r[i][j]);
res += (g[i][j]-b[i][j]);
res += 2*(255-r[i][j]);
res += 2*(255-b[i][j]);
}
}
return ((lf) res)/((lf)(h*w));
}
lf calc_white(){
lld res = 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(r[i][j]>165&&g[i][j]>165&&b[i][j]>165) res++;
}
}
return ((lf) res)/((lf)(h*w));
}
lf calc_global_noise(){
lld res = 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
for(int ii=max(i-5,0);ii<=min(i+5, h-1);ii++){
for(int jj=max(j-5,0);jj<=min(j+5, w-1);jj++){
res += (g[ii][jj]-g[i][j])*(g[ii][jj]-g[i][j]);
res += (r[ii][jj]-r[i][j])*(r[ii][jj]-r[i][j]);
res += (b[ii][jj]-b[i][j])*(b[ii][jj]-b[i][j]);
}
}
}
}
return ((lf) res)/((lf)(h*w));
}
lf calc_local_noise(){
lld res = 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
for(int ii=max(i-1,0);ii<=min(i+1, h-1);ii++){
for(int jj=max(j-1,0);jj<=min(j+1, w-1);jj++){
res += (g[ii][jj]-g[i][j])*(g[ii][jj]-g[i][j]);
res += (r[ii][jj]-r[i][j])*(r[ii][jj]-r[i][j]);
res += (b[ii][jj]-b[i][j])*(b[ii][jj]-b[i][j]);
}
}
}
}
return ((lf) res)/((lf)(h*w));
}
lf calc_diff(){
set<pair<pair<int, int>, int>> used;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
used.insert({{r[i][j]/10, g[i][j]/10}, b[i][j]/10});
}
}
lld res = (lld) used.size();
return ((lf) res);
}
bool visited[500][500];
const int dx[8] = {1,0,-1,0,-1,1,-1,1}, dy[8] = {0,1,0,-1,-1,-1,1,1};
const int CLOSE = 20;
void bfs(int inix, int iniy){
queue<pair<int, int>> q;
q.push({inix,iniy});
visited[inix][iniy];
int x,y;
while(!q.empty()){
auto now = q.front(); q.pop();
x = now.first; y = now.second;
int newx, newy;
for(int i=0;i<8;i++){
newx = x+dx[i]; newy = y+dy[i];
if(newx<0||newx>=h||newy<0||newy>=w) continue;
if(abs(r[x][y]-r[newx][newy])>CLOSE||abs(g[x][y]-g[newx][newy])>CLOSE||abs(b[x][y]-b[newx][newy])>CLOSE) continue;
if(visited[newx][newy]) continue;
visited[newx][newy] = true;
q.push({newx, newy});
}
}
return;
}
lf calc_comps(){
memset(visited, false, sizeof visited);
lld res = 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(!visited[i][j]){
bfs(i, j);
res++;
}
}
}
return 10000.00000000*((lf) res)/((lf)(h*w));
}
int style(int _H, int _W, int _R[500][500], int _G[500][500], int _B[500][500]){
h = _H; w = _W;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
r[i][j] = _R[i][j]; g[i][j] = _G[i][j]; b[i][j] = _B[i][j];
}
}
lf green = calc_green();
lf white = calc_white();
lf global_noise = calc_global_noise();
lf local_noise = calc_local_noise();
lf comps = calc_comps();
//lf diff = calc_diff();
//cout << comps << endl;
if(global_noise<200000&&local_noise<2000) return 4;
if(global_noise>500000&&local_noise>12500&&comps>300) return 3;
if(green*(1-white)>450) return 2;
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |