# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
280538 | amoo_safar | 미술 수업 (IOI13_artclass) | C++17 | 117 ms | 21624 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |