# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168022 | davitmarg | 미술 수업 (IOI13_artclass) | C++17 | 114 ms | 31988 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*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 = 50;
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 (green >= n * m / 2)
return 2;
return rand() % 4 + 1;
if (cnt < 20)
return 4;
if (cnt < 50)
return 1;
return 3;
}
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |