제출 #103027

#제출 시각아이디문제언어결과실행 시간메모리
103027naoai미술 수업 (IOI13_artclass)C++14
62 / 100
198 ms3404 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; bool style4 (int H, int W, int R[500][500], int G[500][500], int B[500][500]) { long long val = 0; for (int i = 0; i < H; ++ i) { int lg = 1; for (int j = 1; j < W; ++ j) { if (abs(R[i][j] - R[i][j - 1]) <= 20 && abs(G[i][j] - G[i][j - 1]) <= 20 && abs(B[i][j] - B[i][j - 1]) <= 20) { ++ lg; } else { val += 1LL * lg * lg; lg = 1; } } val += 1LL * lg * lg; } if (val > 0.8 * H * W * W) { return 1; } val = 0; for (int j = 0; j < W; ++ j) { int lg = 1; for (int i = 1; i < H; ++ i) { if (abs(R[i][j] - R[i - 1][j]) <= 20 && abs(G[i][j] - G[i - 1][j]) <= 20 && abs(B[i][j] - B[i - 1][j]) <= 20) { ++ lg; } else { val += 1LL * lg * lg; lg = 1; } } val += 1LL * lg * lg; } if (val > 0.8 * W * H * H) { return 1; } return 0; } bool style2 (int H, int W, int R[500][500], int G[500][500], int B[500][500]) { int cnt = 0; for (int i = 0; i < H; ++ i) for (int j = 0; j < W; ++ j) { if (G[i][j] > (R[i][j] + B[i][j]) / 2) ++ cnt; } // cout << cnt << " " << H * W << "\n"; if (cnt > 0.40 * H * W) return 1; return 0; } static const int dl[4] = {-1, 0, 0, 1}; static const int dc[4] = {0, -1, 1, 0}; static const int inf = 1 << 30; bool style1 (int H, int W, int R[500][500], int G[500][500], int B[500][500]) { int cnt = 0; int ct = 7; for (int i = 0; i < H; ++ i) { for (int j = 0; j < W; ++ j) { bool ok = 1; for (int p = max(0, i - ct); p < min(H, i + ct) && ok; ++ p) { for (int q = max(0, j - ct); q < min(W, j + ct) && ok; ++ q) { if (abs(R[i][j] - R[p][q]) + abs(G[i][j] - G[p][q]) + abs(B[i][j] - B[p][q]) > 50) ok = 0; } } cnt += ok; } } if (cnt > 0.20 * H * W) return 1; return 0; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { if (style4(H, W, R, G, B)) return 4; if (style1(H, W, R, G, B)) return 1; if (style2(H, W, R, G, B)) return 2; return 3; }
#Verdict Execution timeMemoryGrader output
Fetching results...