Submission #599374

#TimeUsernameProblemLanguageResultExecution timeMemory
599374KarolZDango Maker (JOI18_dango_maker)C++14
13 / 100
1 ms340 KiB
#include<iostream> #include<queue> using namespace std; int t[3010][3010]; int il[3010][3010]; priority_queue< pair<int,pair<pair<int,int>,bool> > >pq; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m,licz=0,x,y,kt; string s; cin>>n>>m; for(int i=2;i<=n+1;i++){ cin>>s; for(int j=2;j<=m+1;j++){ if(s[j-2]=='R')t[i][j]=1; if(s[j-2]=='G')t[i][j]=2; if(s[j-2]=='W')t[i][j]=3; } } for(int i=2;i<=n+1;i++){ for(int j=2;j<=m+1;j++){ if(t[i][j]==1){ if(t[i][j+1]==2&&t[i][j+2]==3){ il[i][j]++; il[i][j+1]++; il[i][j+2]++; licz++; } if(t[i+1][j]==2&&t[i+2][j]==3){ il[i][j]++; il[i+1][j]++; il[i+2][j]++; licz++; } } } } //cout<<licz<<'\n'; for(int i=2;i<=n+1;i++){ for(int j=2;j<=m+1;j++){ if(t[i][j]==1){ if(t[i][j+1]==2&&t[i][j+2]==3){ pq.push({il[i][j]+il[i][j+1]+il[i][j+2],{{i,j},0}}); } if(t[i+1][j]==2&&t[i+2][j]==3){ pq.push({il[i][j]+il[i+1][j]+il[i+2][j],{{i,j},1}}); } } } } while(!pq.empty()){ if(pq.top().first==3)break; x=pq.top().second.first.first; y=pq.top().second.first.second; kt=pq.top().second.second; pq.pop(); if(kt==0){ if(il[x][y]+il[x][y+1]+il[x][y+2]>3){ licz--; il[x][y]--; il[x][y+1]--; il[x][y+2]--; } } if(kt==1){ if(il[x][y]+il[x+1][y]+il[x+2][y]>3){ licz--; il[x][y]--; il[x+1][y]--; il[x+2][y]--; } } } cout<<licz; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...