Submission #761560

#TimeUsernameProblemLanguageResultExecution timeMemory
761560gggkikJOI 문장 (JOI14_ho_t1)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; const int MXN = 1005; char A[MXN][MXN], c[5][5]; int n, m; int ck(int x,int y){ int o = 1; for(int i = 0;i<2;i++) for(int j = 0;j<2;j++) if(A[x+i-1][y+j-1]!=c[i][j]) o = 0; return o; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i = 0;i<n;i++){ for(int j = 0;j<m;j++) cin >> A[i][j]; } for(int i = 0;i<2;i++) for(int j = 0;j<2;j++) cin >> c[i][j]; int cnt = 0; for(int i = 1;i<n;i++) for(int j = 1;j<m;j++){ cnt += ck(i,j); } string L = "JOI"; int ans = 0; for(int i = 0;i<n;i++){ for(int j = 0;j<m;j++){ char k = A[i][j]; int down = 0, up = 0; for(int di = 0;di<2;di++) for(int dj = 0;dj<2;dj++) if(i+di && j+dj) down += ck(i+di,j+dj); for(auto l : L) { A[i][j] = l; for(int di = 0;di<2;di++) for(int dj = 0;dj<2;dj++) if(i+di && j+dj) up += ck(i+di,j+dj); ans = max(ans,cnt-down+up); } A[i][j] = k; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...