Submission #940449

#TimeUsernameProblemLanguageResultExecution timeMemory
940449shenfe1Art Class (IOI13_artclass)C++17
0 / 100
73 ms10712 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=30; 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++; } } } if(cnt<h*w*1.0/15)ok=0; // cout<<cnt<<"\n"; 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)cnt++; } if(cnt<sz(vec)*9.0/10){ ok--; } } } } 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++; } if(cnt<W*9.0/10){ is4=0; } } if(is4==1)return 4; return -1; 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")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...