Submission #1076247

#TimeUsernameProblemLanguageResultExecution timeMemory
1076247TheQuantiXArt Class (IOI13_artclass)C++17
40 / 100
46 ms6236 KiB
#include <bits/stdc++.h> #include "artclass.h" using namespace std; using ll = long long; float dist(float a, float b, float c, float a1, float b1, float c1) { a /= 255; b /= 255; c /= 255; a1 /= 255; b1 /= 255; c1 /= 255; return (abs(a - a1) + abs(b - b1) + abs(c - c1)) / 3.; } float zones(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { vector< vector<bool> > vis(H, vector<bool> (W)); float ans = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (vis[i][j]) { continue; } ans++; queue< pair<ll, ll> > q; q.push({i, j}); vis[i][j] = 1; while (!q.empty()) { auto p = q.front(); q.pop(); if (p.first > 0 && !vis[p.first - 1][p.second] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first - 1][p.second], G[p.first - 1][p.second], B[p.first - 1][p.second]) < 0.2) { q.push({p.first - 1, p.second}); vis[p.first - 1][p.second] = 1; } if (p.second > 0 && !vis[p.first][p.second - 1] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first][p.second - 1], G[p.first][p.second - 1], B[p.first][p.second - 1]) < 0.2) { q.push({p.first, p.second - 1}); vis[p.first][p.second - 1] = 1; } if (p.first < H - 1 && !vis[p.first + 1][p.second] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first + 1][p.second], G[p.first + 1][p.second], B[p.first + 1][p.second]) < 0.2) { q.push({p.first + 1, p.second}); vis[p.first + 1][p.second] = 1; } if (p.second < W - 1 && !vis[p.first][p.second + 1] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first][p.second + 1], G[p.first][p.second + 1], B[p.first][p.second + 1]) < 0.2) { q.push({p.first, p.second + 1}); vis[p.first][p.second + 1] = 1; } } } } ans /= (H / 100.); ans /= (W / 100.); return ans; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { mt19937 gen(chrono::system_clock::now().time_since_epoch().count()); auto f1 = zones(H, W, R, G, B); if (f1 < 0.5) { return 4; } else if (f1 < 31) { return 2; } else if (f1 < 150) { return 1; } else { return 3; } }
#Verdict Execution timeMemoryGrader output
Fetching results...