Submission #168031

#TimeUsernameProblemLanguageResultExecution timeMemory
168031davitmargArt Class (IOI13_artclass)C++17
2 / 100
105 ms30896 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <stack> #include <cassert> #include <iterator> #include <fstream> #define mod 1000000009ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(), v.end() using namespace std; const int N = 505; #ifndef death #include "artclass.h" #endif int n, m, used[N][N], r[N][N], g[N][N], b[N][N], D; bool inRange(int y, int x) { return (min(y, x) > 0 && y <= n && x <= m); } int dist(int y, int x, int Y, int X) { return abs(r[y][x] - r[Y][X]) + abs(g[y][x] - g[Y][X]) + abs(b[y][x] - b[Y][X]); } void dfs(int y, int x) { used[y][x] = 1; int Y, X; Y = y + 1; X = x; if (inRange(Y, X) && !used[Y][X] && dist(y, x, Y, X) <= D) dfs(Y, X); Y = y - 1; X = x; if (inRange(Y, X) && !used[Y][X] && dist(y, x, Y, X) <= D) dfs(Y, X); Y = y; X = x + 1; if (inRange(Y, X) && !used[Y][X] && dist(y, x, Y, X) <= D) dfs(Y, X); Y = y; X = x - 1; if (inRange(Y, X) && !used[Y][X] && dist(y, x, Y, X) <= D) dfs(Y, X); } 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 <= n; i++) for (int j = 1; j <= m; 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]; } int green = 0; int cnt = 0; D = 200; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { green += (g[i][j] >= 50 && r[i][j] + b[i][j] <= 230); if (used[i][j]) continue; cnt++; dfs(i, j); } if (cnt < 10) return 4; if (cnt < 40) return 1; if (green >= n * m * 3 / 4) return 3; return rand() % 2 + 2; } #ifdef death int main() { return 0; } #endif /* 7 5 1 0 1 5 1 2 3 2 3 2 1 4 4 4 5 2 8 6 100 0 1 10 1 2 15 2 7 11 3 4 3 4 5 332 5 6 3 12 8 2 0 8 4 8 2 2 2 7 4 5 11 3 5 1 7 1 3 1 1 9 5 10 6 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...