Submission #940454

#TimeUsernameProblemLanguageResultExecution timeMemory
940454shenfe1Art Class (IOI13_artclass)C++17
0 / 100
64 ms12240 KiB
#include <bits/stdc++.h> #pragma optimize("Ofast") #pragma target("avx2") using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define pii pair<int,int> #define all(v) v.begin(),v.end() #define F first #define S second #define mem(a,i) memset(a,i,sizeof(a)) #define sz(s) (int)s.size() #define y1 yy #define ppb pop_back #define lb lower_bound #define ub upper_bound #define gcd(a,b) __gcd(a,b) #define in insert // #define int ll const int MAX=500+15; const ll inf=1e9; const int mod=1e9+7; const int mod1=1e9+9; const ld eps=1e-9; int dx[8]={1,0,-1,0,1,-1,-1,1}; int dy[8]={0,1,0,-1,1,-1,1,-1}; int binpow(int a,int n){ if(!n)return 1; if(n%2==1)return a*binpow(a,n-1); int k=binpow(a,n/2); return k*k; } #include "artclass.h" int r[MAX][MAX],g[MAX][MAX],b[MAX][MAX]; int isBorder[MAX][MAX]; int h,w; vector<pii> vec; int use[MAX][MAX]; bool good(int i,int j){ return (0<=i&&i<h&&0<=j&&j<w); } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h=H; w=W; int C1=20; ld ch1=0,ch4=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]; } { int ok=5; int cnt=0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(abs(max({R[i][j],G[i][j],B[i][j]})-min({R[i][j],G[i][j],B[i][j]}))<=C1&&max({R[i][j],G[i][j],B[i][j]})<=128){ isBorder[i][j]=1; cnt++; } } } ch1+=cnt*1.0/H/W; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(!isBorder[i][j]&&!use[i][j]){ vec.clear(); queue<pii> q; q.push({i,j}); use[i][j]=1; while(!q.empty()){ int x=q.front().F,y=q.front().S; vec.pb({x,y}); q.pop(); use[x][y]=1; for(int k=0;k<8;k++){ int nx=x+dx[k]; int ny=y+dy[k]; if(good(nx,ny)&&!isBorder[nx][ny]&&!use[nx][ny]){ use[nx][ny]=1; q.push({nx,ny}); } } } // return -1; ld mr=0,mb=0,mg=0; for(auto x:vec){ mr+=R[x.F][x.S]; mb+=B[x.F][x.S]; mg+=G[x.F][x.S]; } if(vec.empty())continue; mr/=sz(vec); mb/=sz(vec); mg/=sz(vec); int cnt=0; for(auto x:vec){ if(abs(R[x.F][x.S]-mr)<=C1*2&&abs(G[x.F][x.S]-mg)<=C1*2&&abs(B[x.F][x.S]-mb)<=C1*2){ ch1+=1.0/H/W; } } } } } if(ok>0)return 1; } bool is4=1; int C=40; for(int i=0;i<H;i++){ int cnt=0; ld mr=0,mb=0,mg=0; for(int j=0;j<W;j++){ mr+=R[i][j]; mb+=B[i][j]; mg+=G[i][j]; } mr/=W; mb/=W; mg/=W; for(int j=0;j<W;j++){ if(abs(R[i][j]-mr)<=C&&abs(G[i][j]-mg)<=C&&abs(B[i][j]-mb)<=C)cnt++; } ch4+=1.0*cnt/H/W; } if(ch1>ch4&&ch1>=0.7){ return 1; } if(ch4>=0.7)return 4; // return -1; if(is4==1)return 4; int cnt=0; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(G[i][j]>=R[i][j]&&G[i][j]>=200&&B[i][j]<=100){ cnt++; } if(R[i][j]>=200&&G[i][j]>=100&&G[i][j]<=200&&B[i][j]<=150){ cnt++; } } } if(cnt>=H*W*8.5/10){ return 2; } return 3; }

Compilation message (stderr)

artclass.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize("Ofast")
      | 
artclass.cpp:4: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    4 | #pragma target("avx2")
      | 
artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:108:15: warning: unused variable 'cnt' [-Wunused-variable]
  108 |           int cnt=0;
      |               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...