제출 #1261543

#제출 시각아이디문제언어결과실행 시간메모리
1261543Bui_Quoc_CuongDango Maker (JOI18_dango_maker)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i <= (int)b; i++) #define FORD(i, a, b) for(int i = a; i >= (int)b; i--) const int N = 3e5 + 5; int n, m; int a[3005][3005]; int dpRow[3005][3005], dpCol[3005][3005], dp[3005][3005]; int is_dango(int x, int y, int z) { vector <int> res; res.push_back(x); res.push_back(y); res.push_back(z); sort(res.begin(), res.end()); return res[0] == 1 && res[1] == 2 && res[2] == 3; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); #define ko "kieuoanh" if (fopen(ko".inp", "r")) { freopen(ko".inp", "r", stdin); freopen(ko".out", "w", stdout); } cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char x; cin >> x; if (x == 'R') a[i][j] = 1; if (x == 'G') a[i][j] = 2; if (x == 'W') a[i][j] = 3; } } for (int i = 1; i <= n; i++) { for (int j = 3; j <= m; j++) { dpRow[i][j] = dpRow[i][j - 1]; if (is_dango(a[i][j - 2], a[i][j - 1], a[i][j])) { dpRow[i][j] = max(dpRow[i][j], dpRow[i][j - 3] + 1); } } } for (int j = 1; j <= m; j++) { for (int i = 3; i <= n; i++) { dpCol[i][j] = dpCol[i - 1][j]; if (is_dango(a[i - 2][j], a[i - 1][j], a[i][j])) { dpCol[i][j] = max(dpCol[i][j], dpCol[i - 3][j] + 1); } } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i >= 1) dp[i][j] = max(dp[i][j], dp[i - 1][j] + dpRow[i][j]); if (j >= 1) dp[i][j] = max(dp[i][j], dp[i][j - 1] + dpCol[i][j]); } } cout << dp[n][m]; cerr << "\n[Time Elapsed] " << 0.001 * clock() << "s\n"; return 0; }

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

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