제출 #72566

#제출 시각아이디문제언어결과실행 시간메모리
72566RezwanArefin01미술 수업 (IOI13_artclass)C++17
0 / 100
222 ms66560 KiB
#include <bits/stdc++.h> #include "artclass.h" using namespace std; int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; struct point { int r, g, b; point(int _r = 0, int _g = 0, int _b = 0) : r(_r), g(_g), b(_b) {} } p[500][500]; int n, m; int sq(int x) { return x * x; } double dist(point a, point b) { return sqrt(sq(a.r - b.r) + sq(a.b - b.b) + sq(a.g - b.g)); } double get_noise() { int cnt = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { int diff = 0; for(int k = 0; k < 8; k++) { int ii = i + dx[k], jj = j + dy[k]; if(ii >= 0 && ii < n && jj >= 0 && jj < m) if(dist(p[i][j], p[ii][jj]) > 10) diff++; } if(diff >= 5) cnt++; } } return (double) cnt / (n * m); } double get_close(vector<point> q) { double ret = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { double x = 100000; for(int k = 0; k < q.size(); k++) { x = min(x, dist(p[i][j], q[k])); } ret += x; } } return ret / (n * m); } int vis[500][500]; void fill(int x, int y) { vis[x][y] = 1; for(int i = 0; i < 4; i++) { int xx = x + dx[i], yy = y + dy[i]; if(xx >= 0 && xx < n && yy >= 0 && yy < m && !vis[xx][yy]) if(dist(p[x][y], p[xx][yy]) <= 15) fill(xx, yy); } } int get_comp() { int ret = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) if(!vis[i][j]) { ++ret; fill(i, j); } } return ret; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { n = H, m = W; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { p[i][j] = point{R[i][j], G[i][j], B[i][j]}; } } double noise = get_noise(); double green = get_close({{198, 201, 220}, {98, 38, 28}, {234, 152, 131},{68, 71, 26}, {40, 40, 40}, {29, 39, 12}, {21, 77, 48}, {40, 27, 19}}); double tile = get_close({{255,255,0}, {255,0,0}, {255,255,255}, {0,0,0}, {0,0,255}, {179,184,204}, {218, 164, 6}, {173, 195, 216}}); double comp = get_comp(); if(comp <= 600) return 4; if(tile <= 60) return 1; if(noise >= 0.4 && green <= 53) return 2; if(noise >= 0.7) return 3; return 1 + rand() % 4; }

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'double get_close(std::vector<point>)':
artclass.cpp:39:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int k = 0; k < q.size(); k++) {
                            ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...