Submission #914757

#TimeUsernameProblemLanguageResultExecution timeMemory
914757May27_thDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms2512 KiB
#include <bits/stdc++.h> #define int64_t long long #define double long double using namespace std; using type = int64_t; const long long mod = 1000000007, inf = 1e18; const int base = 33; const int N = 2e5 + 10; const int LG = 20; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; void Minimize(int64_t &a, int64_t b) {if(b < a) a = b;} void Maximize(int &a, int b) {if(b > a) a = b;} void Add(int64_t& a, int64_t b) {a = a + b; a %= mod;} void Dec(int64_t& a, int64_t b) {a = a - b + mod; a %= mod;} int n, m; char d[3005][3005]; int f[3005][3004]; bool h(int i, int j) { return (d[i][j] == 'W') && (d[i][j - 1] == 'G') && (d[i][j - 2] == 'R'); } bool v(int i, int j) { return (d[i][j] == 'W') && (d[i - 1][j] == 'G') && (d[i - 2][j] == 'R'); } void Solve(void) { /** tim so cach xien que sao cho thu tu la R, G, W **/ cin >> n >> m; for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ cin >> d[i][j]; } } for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ for(int z = 2; z <= 3; z ++){ Maximize(f[i][j], f[i][max(j - z, 0)] + f[i - 1][j] - f[i - 1][max(j - z, 0)]); Maximize(f[i][j], f[i][j - 1] + f[max(i - z, 0)][j] - f[max(i - z, 0)][j - 1]); } if(j >= 3){ if(h(i, j)){ Maximize(f[i][j], 1 + f[i][j - 3] + f[i - 1][j] - f[i - 1][j - 3]); } } if(i >= 3){ if(v(i, j)){ Maximize(f[i][j], 1 + f[i][j - 1] + f[i - 3][j] - f[i - 3][j - 1]); } } //cout << f[i][j] << " "; } //cout << "\n"; } cout << f[n][m]; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); if(fopen("poetry.in", "r")){ freopen("poetry.in", "r", stdin); freopen("poetry.out", "w", stdout); } if(fopen("A.inp", "r")){ freopen("A.inp", "r", stdin); freopen("A.out", "w", stdout); } int tc = 1; //cin >> tc; while(tc --){ Solve(); } }

Compilation message (stderr)

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