# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
554111 | elazarkoren | Art Class (IOI13_artclass) | C++17 | 61 ms | 3312 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "artclass.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
const int infinity = 1e9;
struct Style{
int red, green, blue, gray, diff;
Style() {}
Style(int r, int g, int b, int gr, int diff): red(r), green(g), blue(b), gray(gr), diff(diff) {}
int Close(int r, int g, int b, int gr) {
return abs(r - red) + abs(g - green) + abs(b - blue) + abs(gr - gray);
}
bool Ok(int r, int g, int b, int gr) {
return Close(r, g, b, gr) <= diff * 1.5;
}
};
Style s[] = {Style(), Style(146, 166, 146, 167, 104), Style(67, 97, 63, 87, 70), Style(106, 128, 106, 124, 95), Style(54, 89, 54, 100, 209)};
int cnt[5];
void ClosestR(int x) {
int ans = infinity;
for (int i = 1; i <= 4; i++) {
chkmin(ans, abs(x - s[i].red));
}
for (int i = 1; i <= 4; i++) {
if (abs(x - s[i].red) == ans) {
cnt[i]++;
}
}
}
void ClosestG(int x) {
int ans = infinity;
for (int i = 1; i <= 4; i++) {
chkmin(ans, abs(x - s[i].green));
}
for (int i = 1; i <= 4; i++) {
if (abs(x - s[i].green) == ans) {
cnt[i]++;
}
}
}
void ClosestB(int x) {
int ans = infinity;
for (int i = 1; i <= 4; i++) {
chkmin(ans, abs(x - s[i].blue));
}
for (int i = 1; i <= 4; i++) {
if (abs(x - s[i].blue) == ans) {
cnt[i]++;
}
}
}
void ClosestGr(int x) {
int ans = infinity;
for (int i = 1; i <= 4; i++) {
chkmin(ans, abs(x - s[i].gray));
}
for (int i = 1; i <= 4; i++) {
if (abs(x - s[i].gray) == ans) {
cnt[i]++;
}
}
}
int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
ll sum_r = 0, sum_g = 0, sum_b = 0, gray_scale = 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];
gray_scale += (r[i][j] + g[i][j] + b[i][j]) / 3;
}
}
sum_r /= (h * w);
sum_g /= (h * w);
sum_b /= (h * w);
gray_scale /= (h * w);
//cnt[1] = cnt[2] = cnt[3] = cnt[4] = 0;
//ClosestR(sum_r), ClosestG(sum_g), ClosestB(sum_b), ClosestGr(gray_scale);
int max_cnt = 0;
//for (int i = 1; i <= 4; i++) {
// chkmax(max_cnt, cnt[i]);
//}
pii ans = {infinity, 0};
vi good;
for (int i = 1; i <= 3; i++) {
if (s[i].Ok(sum_r, sum_g, sum_b, gray_scale)) good.push_back(i);
}
if (good.empty()) return 4;
for (int i : good) {
//if (cnt[i] == max_cnt) {
pii q = {s[i].Close(sum_r, sum_g, sum_b, gray_scale), i};
chkmin(ans, q);
//}
}
return ans.y;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |