Submission #757089

# Submission time Handle Problem Language Result Execution time Memory
757089 2023-06-12T14:52:01 Z qwertyqwerty Dango Maker (JOI18_dango_maker) C++17
0 / 100
3 ms 340 KB
// stars only shine in darkness
#include <bits/stdc++.h>
// date:12-06-2023 21:32:47
using namespace std;

#define retardlord ios_base::sync_with_stdio(NULL), cin.tie(NULL);
#define task freopen("dangomaker.inp", "r", stdin), freopen("dangomaker.out", "w", stdout);
const int N = 3e3 + 1;
int n, m;
char a[N][N];
int f[3], f1[3];
//--------------------------------------------------------------------------------------------------
void nhap()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
}
//--------------------------------------------------------------------------------------------------
void xuly()
{
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {

            if (a[i][j] == 'G')
            {
                f1[0] = f1[1] = f1[2] = -1e7;
                f1[0] = max({f[0], f[1], f[2]});
                if (j - 1 >= 1 && j + 1 <= m && a[i][j - 1] == 'R' && a[i][j + 1] == 'W')
                    f1[1] = max(f[0], f[1]) + 1;
                if (i - 1 >= 1 && i + 1 <= n && a[i - 1][j] == 'R' && a[i + 1][j] == 'W')
                    f1[2] = max(f[0], f[2]) + 1;
                f[0] = f1[0], f[1] = f1[1], f[2] = f1[2];
            }
            else
            {
                f[0] = max({f[0], f[1], f[2]});
                f[1] = f[2] = -1e7;
            }
        }
    }
    ans += max({f[0], f[1], f[2]});
    cout << ans;
}
//--------------------------------------------------------------------------------------------------
signed main()
{
    retardlord;
#ifndef ONLINE_JUDGE
    task;
#endif
    nhap();
    xuly();
    return 0;
}
//--------------------------------------------------------------------------------------------------

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:7:21: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | #define task freopen("dangomaker.inp", "r", stdin), freopen("dangomaker.out", "w", stdout);
      |              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:54:5: note: in expansion of macro 'task'
   54 |     task;
      |     ^~~~
dango_maker.cpp:7:60: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | #define task freopen("dangomaker.inp", "r", stdin), freopen("dangomaker.out", "w", stdout);
      |                                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:54:5: note: in expansion of macro 'task'
   54 |     task;
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -