Submission #280529

#TimeUsernameProblemLanguageResultExecution timeMemory
280529amoo_safarArt Class (IOI13_artclass)C++17
4 / 100
100 ms23288 KiB
#include "artclass.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; typedef pair<int, int> pii; const int N = 510; int H, W; int R[N][N], G[N][N], B[N][N]; int mk[N][N]; const int Tr = 50; bool Same(int X1, int Y1, int X2, int Y2){ return abs(R[X1][Y1] - R[X2][Y2]) + abs(R[X1][Y1] - R[X2][Y2]) + abs(R[X1][Y1] - R[X2][Y2]) <= Tr; } bool Valid(int X1, int Y1){ return (0 <= X1) && (X1 < H) && (0 <= Y1) && (Y1 < W); } pii del[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; void DFS(int X, int Y, int c){ mk[X][Y] = 1; int nx, ny; for(auto [dx, dy] : del){ nx = X + dx; ny = Y + dy; if(!Valid(nx, ny)) continue; if(mk[nx][ny]) continue; if(Same(X, Y, nx, ny)) DFS(nx, ny, c); } } int style(int _H, int _W, int _R[500][500], int _G[500][500], int _B[500][500]) { H = _H; W = _W; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ R[i][j] = _R[i][j]; G[i][j] = _G[i][j]; B[i][j] = _B[i][j]; } } int cnt = 0; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(mk[i][j]) continue; cnt ++; DFS(i, j, cnt); } } cerr << H << ", " << W << ' ' << cnt << '\n'; if(cnt < 8) return 4; if(cnt < 20) return 1; if(cnt >= 80) return 3; return 2; assert(false); }
#Verdict Execution timeMemoryGrader output
Fetching results...