제출 #1165703

#제출 시각아이디문제언어결과실행 시간메모리
1165703nguynDango Maker (JOI18_dango_maker)C++20
100 / 100
168 ms9308 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define F first
#define S second
#define pb push_back 
#define pii pair<int,int>

const int N = 2e5 + 5;

int f[3005][3], n, m;
char a[3005][3005];

bool horizontal(int i, int j) {
	if (j <= 2) return 0; 
	if (a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R') {
		return 1;
	}
	return 0;
}

bool vertical(int i, int j) {
	if (i <= 2) return 0; 
	if (a[i][j] == 'W' &&  a[i - 1][j] == 'G' && a[i - 2][j] == 'R') {
		return 1;
	}
	return 0; 
}

signed main(){
    ios_base::sync_with_stdio(false) ; 
    cin.tie(0) ; cout.tie(0) ; 
    if (fopen("INP.INP" ,"r")) {
        freopen("INP.INP" ,"r" , stdin) ;
        freopen("OUT.OUT" , "w" , stdout) ;
    }
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		cin >> a[i][j]; 
    	}
    }
    int res = 0; 
    for (int d = 1; d < m + n; d++) {
    	memset(f, 0, sizeof(f)); 
    	for (int i = max(1, d - m + 1); i <= min(n, d); i++) {
    		int j = d - i + 1; 
    		for (int t = 0; t < 3; t++) f[i][0] = max(f[i][0], f[i - 1][t]); 
    		if (horizontal(i, j)) {
    			f[i][1] = max(f[i][1], f[i][0] + 1); 
    		}
    		if (vertical(i, j)) {
    			f[i][2] = max(f[i][2], f[i - 1][2] + 1);
    			if (i >= 2) {
    				f[i][2] = max(f[i][2], f[i - 2][0] + 1); 
    				f[i][2] = max(f[i][2], f[i - 2][2] + 1);
    			}
    		}
    	}	
    	int tmp = 0;
    	for (int j = 0; j < 3; j++) {
    		tmp = max(tmp, f[min(n, d)][j]);
    	}
    	res += tmp;
    }
    cout << res;
}

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen("INP.INP" ,"r" , stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen("OUT.OUT" , "w" , stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...