# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012493 | amirhoseinfar1385 | Art Class (IOI13_artclass) | C++17 | 50 ms | 14676 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>
using namespace std;
const int maxn=500+10;
int vis[maxn][maxn],all[maxn][maxn],n=500;
void dfs(int i,int j){
if(i<1||i>n||j<1||j>n||vis[i][j]==1||all[i][j]==0){
return ;
}
vis[i][j]=1;
for(int a=-1;a<=1;a++){
for(int b=-1;b<=1;b++){
dfs(i+a,j+b);
}
}
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
int cnt=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(R[i][j]+G[i][j]+B[i][j]==0){
all[i][j]=1;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(vis[i][j]==0&&all[i][j]==1){
dfs(i,j);
cnt++;
}
}
}
if(cnt<=2){
return 1;
}
return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |