# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
296680 | williamMBDK | Art Class (IOI13_artclass) | C++14 | 318 ms | 7800 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<bits/stdc++.h>
using namespace std;
#include "artclass.h"
// difference in size of components
int H, W, R[500][500], G[500][500], B[500][500];
vector<pair<int,int>> dirs = {{-1,0},{1,0},{0,-1},{0,1}};
bool isedge(pair<int,int> p1, pair<int,int> p2){
int dr = abs(R[p1.first][p1.second] - R[p2.first][p2.second]);
int dg = abs(G[p1.first][p1.second] - G[p2.first][p2.second]);
int db = abs(B[p1.first][p1.second] - B[p2.first][p2.second]);
int diff = dr * dr + dg * dg + db * db;
return diff < 10000;
}
int style(int _H, int _W, int _R[500][500], int _G[500][500], int _B[500][500]) {
H = _H;
W = _W;
int sc1 = 0, sc2 = 0, sc3 = 0, sc4 = 0;
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];
sc2 += (G[i][j] > 200);
}
}
vector<vector<bool>> v (H, vector<bool> (W));
int c = 0;
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(!v[i][j]){
int size = 0;
queue<pair<int,int>> q;
q.push({i,j});
while(!q.empty()){
auto curr = q.front(); q.pop();
if(v[curr.first][curr.second]) continue;
v[curr.first][curr.second] = 1;
size++;
for(auto dir : dirs){
int ni = curr.first + dir.first;
int nj = curr.second + dir.second;
if(ni >= 0 && ni < H && nj >= 0 && nj < W && isedge(curr, {ni,nj})){
q.push({ni, nj});
}
}
}
c += (size != 1);
}
}
}
// cout << c << endl;
if(c < 5) {
if(sc2 > 10000) return 2;
return 4;
}
if(c < 50) return 1;
return 3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |