제출 #95415

#제출 시각아이디문제언어결과실행 시간메모리
95415easruiJOI 문장 (JOI14_ho_t1)C++14
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 1e3+5; int M,N,ans,res; char F[MAX][MAX],K[2][2],B[3]={'J','O','I'}; int C[MAX][MAX]; int match(int a, int b, int x, int y, char c) { if(a<1 || a>=M || b<1 || b>=N) return 0; for(int i=0; i<2; i++) for(int j=0; j<2; j++) { if(a+i==x && b+j==y) { if(c!=K[i][j]) return 0; } else if(F[a+i][b+j]!=K[i][j]) return 0; } return 1; } int main() { freopen("input.txt","r",stdin); ios_base::sync_with_stdio(0),cin.tie(0); cin >> M >> N; for(int i=1; i<=M; i++) for(int j=1; j<=N; j++) cin >> F[i][j]; for(int i=0; i<2; i++) for(int j=0; j<2; j++) cin >> K[i][j]; for(int i=0; i<=M; i++) for(int j=0; j<=N; j++) { C[i][j] = match(i,j,i,j,F[i][j]); ans += C[i][j]; } for(int i=1; i<=M; i++) for(int j=1; j<=N; j++) for(int k=0; k<3; k++) { res = 0; for(int x=-1; x<=0; x++) for(int y=-1; y<=0; y++) res += match(i+x,j+y,i,j,B[k]) - C[i+x][j+y]; ans = max(ans,ans+res); } cout << ans; }

컴파일 시 표준 에러 (stderr) 메시지

2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...