Submission #1015865

#TimeUsernameProblemLanguageResultExecution timeMemory
1015865snpmrnhlolDango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms2652 KiB
#include<bits/stdc++.h> using namespace std; const int N = 3e3; char v[N][N]; bool vis[N][N][2]; int ans = 0; int n,m; bool ok(int x,int y,int id){ if(id == 0){ return 0 <= x && x <= n - 1 && 0 <= y && y <= m - 3 && (!vis[x][y][id]) && v[x][y] == 'R' && v[x][y + 1] == 'G' && v[x][y + 2] == 'W'; }else{ return 0 <= x && x <= n - 3 && 0 <= y && y <= m - 1 && (!vis[x][y][id]) && v[x][y] == 'R' && v[x + 1][y] == 'G' && v[x + 2][y] == 'W'; } } void dfs(int x,int y,int id){ int cnt0 = 0,cnt1 = 0; //cout<<"iteration:\n"; auto dfs2 = [&](auto self, int x, int y, int id) -> void{ vis[x][y][id] = 1; //cout<<x<<' '<<y<<' '<<id<<'\n'; if(id == 0){ cnt0++; if(ok(x,y,id^1))self(self, x, y, id^1); if(ok(x - 1,y + 1,id^1))self(self, x - 1, y + 1, id^1); if(ok(x - 2,y + 2,id^1))self(self, x - 2, y + 2, id^1); }else{ cnt1++; if(ok(x,y,id^1))self(self, x, y, id^1); if(ok(x + 1,y - 1,id^1))self(self, x + 1, y - 1, id^1); if(ok(x + 2,y - 2,id^1))self(self, x + 2, y - 2, id^1); } }; dfs2(dfs2, x, y, id); ans+=max(cnt0,cnt1); } int main(){ cin>>n>>m; for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ cin>>v[i][j]; } } for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ if(ok(i,j,0)){ dfs(i,j,0); } if(ok(i,j,1)){ dfs(i,j,1); } } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...