# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
897474 | Faisal_Saqib | Art Class (IOI13_artclass) | C++17 | 5057 ms | 17888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "artclass.h"
/*
*/
#include <iostream>
#include <set>
#include <map>
#include <queue>
#define ll long long
using namespace std;
long long val(ll i,ll j,ll k)
{
return (((i*256ll)+j)*256ll)+k;
}
int style(int n, int m, int R[500][500], int G[500][500], int B[500][500])
{
int mx=-1*n*m;
int mi=-mx;
set<vector<int>> st;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
st.insert({R[i][j],G[i][j],B[i][j]});
// run a bfs to find number of cell adjacent and equal
queue<pair<int,int>> q;
map<pair<int,int>,bool> vis;
q.push({i,j});
int sz=0;
while(q.size())
{
auto f=q.front();
sz++;
q.pop();
if((f.first>0) and R[f.first-1][f.second]==R[f.first][f.second] and G[f.first-1][f.second]==G[f.first][f.second] and B[f.first-1][f.second]==B[f.first][f.second] and !vis[{f.first-1,f.second}])
{
vis[{f.first-1,f.second}]=1;
q.push({f.first-1,f.second});
}
if((f.second>0) and R[f.first][f.second-1]==R[f.first][f.second] and G[f.first][f.second-1]==G[f.first][f.second] and B[f.first][f.second-1]==B[f.first][f.second] and !vis[{f.first,f.second-1}])
{
vis[{f.first,f.second-1}]=1;
q.push({f.first,f.second-1});
}
if((f.first<(n-1)) and R[f.first+1][f.second]==R[f.first][f.second] and G[f.first+1][f.second]==G[f.first][f.second] and B[f.first+1][f.second]==B[f.first][f.second] and !vis[{f.first+1,f.second}])
{
vis[{f.first+1,f.second}]=1;
q.push({f.first+1,f.second});
}
if((f.second<(m-1)) and R[f.first][f.second+1]==R[f.first][f.second] and G[f.first][f.second+1]==G[f.first][f.second] and B[f.first][f.second+1]==B[f.first][f.second] and !vis[{f.first,f.second+1}])
{
vis[{f.first,f.second+1}]=1;
q.push({f.first,f.second+1});
}
}
mx=max(mx,sz);
mi=min(mi,sz);
}
}
if(mx<=(n+m+n+m))
{
// We check
if(st.size()>=23)
return 3;
else
{
ll sum=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
sum+=val(R[i][j],G[i][j],B[i][j]);
}
}
sum/=(n*m);
if(sum>=(1e7))
{
return 4;
}
else
{
return 2;
}
}
}
else
{
return 1;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |