Submission #240261

#TimeUsernameProblemLanguageResultExecution timeMemory
240261NightlightArt Class (IOI13_artclass)C++14
2 / 100
188 ms13396 KiB
#include "artclass.h" #include <bits/stdc++.h> #define isg(a, b) ((G[a][b] - R[a][b] > tolG && G[a][b] - B[a][b] > tolG)) #define pii pair<int, int> using namespace std; const int tolG = 20; const int tol = 40; int N, M; int R[505][505]; int G[505][505]; int B[505][505]; set<long long> ada; int green, white, big_green; int baru, cnt_diff, beda; double avg_diff;//avg diff of color under tol double avg_pos_white;//avg ketinggian putih bool ijo(int a, int b) { return ((G[a][b] - R[a][b] > tolG && G[a][b] - B[a][b] > tolG)); } bool putih(int a, int b) { int mx = max(G[a][b], max(R[a][b], B[a][b])); int mn = min(G[a][b], min(R[a][b], B[a][b])); return mx - mn <= 5 && R[a][b] > 0 && B[a][b] > 0 && G[a][b]; } int perbedaan(int a, int b, int c, int d) { return abs(R[a][b] - R[c][d]) + abs(B[a][b] - B[c][d]) + abs(G[a][b] - G[c][d]); } int vis[505][505]; pii par[505][505]; int sz[505][505]; pii findpar(pii u) { return par[u.first][u.second] == u ? u : par[u.first][u.second] = findpar(par[u.first][u.second]); } void merge(int a, int b, int p, int q) { pii u = {a, b}, v = {p, q}; u = findpar(u), v = findpar(v); if(v == u) return; // cout << a << " " << b << " - " << p << " " << q << "\n"; par[v.first][v.second] = u; } void go(int r, int c) { if(r > 1) { int tmp = perbedaan(r, c, r - 1, c); if(tmp <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r - 1, c); } } if(r < N) { int tmp = perbedaan(r, c, r + 1, c); if(tmp <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r + 1, c); } } if(c > 1) { int tmp = perbedaan(r, c, r, c - 1); if(tmp <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r, c - 1); } } if(c < N) { int tmp = perbedaan(r, c, r, c + 1); if(tmp <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r, c + 1); } } } 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 = 1; i <= H; i++) { for(int j = 1; j <= W; j++) { R[i][j] = r[i - 1][j - 1]; G[i][j] = g[i - 1][j - 1]; B[i][j] = b[i - 1][j - 1]; } } for(int i = 1; i <= H; i++) { for(int j = 1; j <= W; j++) { green += ijo(i, j); if(putih(i, j)) { avg_pos_white += i; white++; } long long skrg = 1000000000 * R[i][j] + 1000 * G[i][j] + B[i][j]; if(ada.count(skrg)) beda++; else ada.insert(skrg); go(i, j); } } avg_diff /= cnt_diff; if(avg_diff <= 5.0 && white > H * W / 4) { //petak2 return 1; } if(avg_diff <= 10.0) { return 4; } if(green > H * W / 4) { return 2; } return 3; }
#Verdict Execution timeMemoryGrader output
Fetching results...