# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
29607 | dereotu | 미술 수업 (IOI13_artclass) | C++14 | 193 ms | 22984 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "artclass.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;
int vis[500][500];
int dr[]={1,0,0,-1};
int dl[]={0,1,-1,0};
int green,cnt,advcnt;
int g[500][500],r[500][500],b[500][500];
int h,w;
void type2(int x,int y){
if(vis[x][y]) return;
if(g[x][y]>100 and r[x][y]<100 and b[x][y]<100) green++;
vis[x][y]=1;
forr(i,0,4){
int nx=x+dr[i];
int ny=y+dl[i];
if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){
type2(x+dr[i],y+dl[i]);
}
}
}
void floodfill(int x,int y){
if(vis[x][y]) return;
vis[x][y]=1;
forr(i,0,4){
int nx=x+dr[i];
int ny=y+dl[i];
if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){
if(g[x+dr[i]][y+dl[i]]<=50 and r[x+dr[i]][y+dl[i]]<=50 and b[x+dr[i]][y+dl[i]]<=50) continue;
floodfill(x+dr[i],y+dl[i]);
}
}
}
void advancedflood(int x,int y){
if(vis[x][y]) return;
vis[x][y]=1;
forr(i,0,4){
int nx=x+dr[i];
int ny=y+dl[i];
if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){
if(g[x][y]-g[x+dr[i]][y+dl[i]]>=50 or r[x][y]-r[x+dr[i]][y+dl[i]]>=50 or b[x][y]-b[x+dr[i]][y+dl[i]]>=50) continue;
advancedflood(x+dr[i],y+dl[i]);
}
}
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
type2(0,0);
forr(i,0,500) forr(j,0,500){
r[i][j]=R[i][j];
b[i][j]=B[i][j];
g[i][j]=G[i][j];
}
h=H;
w=W;
if(green>=H*W*0.7) return 2;
forr(i,0,500){
forr(j,0,500){
if(!vis[i][j]){
++cnt;
floodfill(i,j);
}
}
}
memset(vis,0,sizeof vis);
forr(i,0,500){
forr(j,0,500){
if(!vis[i][j]){
++advcnt;
advancedflood(i,j);
}
}
}
if(cnt>=15) return 1;
if(advcnt<=5) return 4;
else return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |