제출 #656273

#제출 시각아이디문제언어결과실행 시간메모리
656273Dec0DeddDango Maker (JOI18_dango_maker)C++14
13 / 100
8 ms9300 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e3+1; string S = "RGW"; char c[N][N], tmp[N][N]; bool us[N][N]; int n, m; void rot90() { for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) tmp[j][n-i+1]=c[i][j]; } swap(n, m); for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) c[i][j]=tmp[i][j]; } } bool ver(int i, int j) { if (j+2 > m) return false; for (int k=0; k<3; ++k) { if (c[i][j+k] != S[k] || us[i][j+k]) return false; } return true; } bool hor(int i, int j) { if (i+2 > n) return false; for (int k=0; k<3; ++k) { if (c[i+k][j] != S[k] || us[i+k][j]) return false; } return true; } int solve() { int ans=0; memset(us, false, sizeof(us)); for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) { if (ver(i, j)) { for (int k=0; k<3; ++k) us[i][j+k]=true; ++ans; } else if (hor(i, j)) { for (int k=0; k<3; ++k) us[i+k][j]=true; ++ans; } } } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) cin>>c[i][j]; } int k=4, ans=0; while (k--) { ans=max(ans, solve()); rot90(); } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...