# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168046 | davitmarg | Art Class (IOI13_artclass) | C++17 | 105 ms | 30900 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.
/*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 cnt = 0;
D = 100;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
if (used[i][j])
continue;
cnt++;
dfs(i, j);
}
if (cnt >= 200)
return 3;
if (cnt >= 70)
return 1;
if (cnt <= 10)
return 4;
return 2;
return rand() % 4 + 1;
}
#ifdef death
int main()
{
return 0;
}
#endif
/*
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |