# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
280538 | amoo_safar | Art Class (IOI13_artclass) | C++17 | 117 ms | 21624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(G[X1][Y1] - G[X2][Y2]) + abs(B[X1][Y1] - B[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){
//cerr << "# " << X << ' ' << Y << '\n';
mk[X][Y] = c;
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]){
//return 1;
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];
}
}
//cerr << H << ' ' << W << '\n';
int cnt = 0;
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(mk[i][j]) continue;
//cerr << i << ' ' << j << '\n';
cnt ++;
DFS(i, j, cnt);
}
}
//cerr << H << ", " << W << ' ' << cnt << '\n';
if(cnt < 8) return 4;
if(cnt < 20) return 1;
if(cnt > 60) return 3;
return 2;
assert(false);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |