# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
753793 | minhcool | Art Class (IOI13_artclass) | C++17 | 64 ms | 4552 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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
return abs(temp) + l;
}
int xx[] = {0, 1, -1, 0};
int yy[] = {1, 0, 0, -1};
bool vis[500][500];
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]){
int cnt = 0, cnt2 = 0;
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if((i + 1) < H){
int sum = abs(R[i][j] - R[i + 1][j]) + abs(G[i][j] - G[i + 1][j]) + abs(B[i][j] - B[i + 1][j]);
if(sum > 80) cnt++;
}
if((j + 1) < W){
int sum = abs(R[i][j] - R[i][j + 1]) + abs(G[i][j] - G[i][j + 1]) + abs(B[i][j] - B[i][j + 1]);
if(sum > 80) cnt++;
}
if(G[i][j] == max({G[i][j], B[i][j], R[i][j]})) cnt2 += 4;
if(B[i][j] == min({G[i][j], B[i][j], R[i][j]})) cnt2++;
}
}
if(cnt * 2 > H * W) return 3;
else if(cnt * 5 <= H * W){
int comp = 0;
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(vis[i][j]) continue;
comp++;
queue<ii> q;
q.push({i, j});
vis[i][j] = 1;
while(!q.empty()){
int x = q.front().fi, y = q.front().se;
q.pop();
// vis[x][y] = 1;
for(int dir = 0; dir < 4; dir++){
int tempx = x + xx[dir], tempy = y + yy[dir];
if(tempx < 0 || tempy < 0 || tempx >= H || tempy >= W) continue;
if(vis[tempx][tempy]) continue;
int diff = abs(R[x][y] - R[tempx][tempy]) + abs(G[x][y] - G[tempx][tempy]) + abs(B[x][y] - B[tempx][tempy]);
if(diff > 50) continue;
q.push({tempx, tempy});
vis[tempx][tempy] = 1;
}
}
}
}
if(comp <= 100) return 4;
else if(comp <= 1500) return 1;
else return 2;
}
else{
return 2;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |