Submission #383579

#TimeUsernameProblemLanguageResultExecution timeMemory
383579alishahali1382Art Class (IOI13_artclass)C++14
25 / 100
99 ms26732 KiB
#include "artclass.h" #include <bits/stdc++.h> #pragma GCC optimize ("O2,unroll-loops") //#pragma GCC optimize("no-stack-protector,fast-math") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<pii, int> piii; typedef pair<ll, ll> pll; #define debug(x) cerr<<#x<<'='<<(x)<<endl; #define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl; #define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl; #define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;} #define all(x) x.begin(), x.end() #define pb push_back #define kill(x) return cout<<x<<'\n', 0; const int inf=1000000010; const ll INF=1000000000000001000LL; const int mod=1000000007; const int MAXN=510, LOG=20; int n, m, k, u, v, x, y, t, a, b, comp, green; int mark[MAXN][MAXN]; int R[MAXN][MAXN], G[MAXN][MAXN], B[MAXN][MAXN]; int dx[]={0, +1, 0, -1}; int dy[]={-1, 0, +1, 0}; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void dfs(int x, int y){ if (x<0 || x>=n || y<0 || y>=m) return ; mark[x][y]++; for (int i=0; i<4; i++){ int xx=x+dx[i], yy=y+dy[i]; if (!mark[xx][yy]){ int diff=abs(R[x][y]-R[xx][yy])+abs(G[x][y]-G[xx][yy])+abs(B[x][y]-B[xx][yy]); if (diff>100) continue ; // 100/768 dfs(xx, yy); } } } int style(int nn, int mm, int RR[500][500], int GG[500][500], int BB[500][500]) { n=nn; m=mm; for (int i=0; i<n; i++) for (int j=0; j<m; j++){ R[i][j]=RR[i][j]; G[i][j]=GG[i][j]; B[i][j]=BB[i][j]; } for (int i=0; i<n; i++) for (int j=0; j<m; j++){ ld r=R[i][j], g=G[i][j], b=B[i][j], sum=r+g+b; if (g/sum>.5) green++; } for (int i=0; i<n; i++) for (int j=0; j<m; j++) if (!mark[i][j]){ dfs(i, j); comp++; } debug(green) debug(comp) if (green>=n*m/3) return 2; if (comp<=5) return 4; if (comp<=25) return 1; return 3; }
#Verdict Execution timeMemoryGrader output
Fetching results...