제출 #1257850

#제출 시각아이디문제언어결과실행 시간메모리
1257850son2008Dango Maker (JOI18_dango_maker)C++20
100 / 100
147 ms15188 KiB
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
#define fi first
#define se second
// #define int long long
#define ll long long
#define ld double
#define mp make_pair
#define lg2 30
#define iii pair<int, ii>
#define iiii pair<ii, ii>
#define base 29
#define eps 1e-8
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
int dx[] = {0LL, 0LL, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0LL, 0LL, 1, -1, 1, -1};
const int maxn = 5e3 + 5;
const int mod = 1e9 + 7;
int n, m;
char a[maxn][maxn];
int dp[maxn][2];
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#define task "task"
    if (fopen(task ".inp", "r"))
    {
        freopen(task ".inp", "r", stdin);
        freopen(task ".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 ans = 0;
    for (int cheo = 1; cheo <= n + m; cheo++)
    {
        memset(dp, 0, sizeof(dp));
        int mx = 0;
        //   cout << cheo << '\n';
        for (int j = min(cheo - 1, m), i = cheo - j; j >= 1 && i <= n; j--, i++)
        {
            //       cout << i << " " << j << '\n';
            dp[j][0] = max(dp[j + 1][0], dp[j + 3][1]) + (a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W');
            dp[j][1] = max(dp[j + 1][0], dp[j + 1][1]) + (a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W');
            mx = max({mx, dp[j][0], dp[j][1]});
        }
        ans += mx;
    }
    cout << ans;
    cerr << endl
         << "TIME : " << clock() * 0.001 << "s" << endl;
}

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

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