Submission #914792

#TimeUsernameProblemLanguageResultExecution timeMemory
914792May27_thDango Maker (JOI18_dango_maker)C++17
0 / 100
2 ms2808 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], add[3005][3005]; 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'); } bool adhoc(int i, int j) { if(i < 3 || j < 3) return false; bool flag = v(i, j - 2) & h(i - 2, j); return flag; } 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 ++){ if(h(i, j) && v(i + 2, j - 2)) add[i + 2][j] ++; if(h(i, j) && v(i + 1, j - 1)) add[i + 1][j] ++; } } for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ int bonus = 0; if(h(i, j) || v(i, j)) bonus = 1; f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + bonus - add[i][j]; //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:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen("poetry.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen("poetry.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen("A.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen("A.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...