Submission #170253

#TimeUsernameProblemLanguageResultExecution timeMemory
170253ZwariowanyMarcinDango Maker (JOI18_dango_maker)C++14
100 / 100
441 ms164728 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define ll long long #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, n) for(int i = 0; i < n; ++i) using namespace std; const int nax = 3111; void maxi(int &a, int b) { a = max(a, b); } int n, m; char s[nax][nax]; bool in(int r, int c) { return 1 <= r && r <= n && 1 <= c && c <= m; } int dp[nax][nax][2][2]; int daj(int r, int c) { int naj = 0; for(int i = 0; i < 2; ++i) for(int j = 0; j < 2; ++j) maxi(naj, dp[r][c][i][j]); return naj; } int main() { scanf("%d %d", &n, &m); for(int i = 1; i <= n; ++i) scanf("%s", s[i] + 1); for(int r = 1; r <= n; ++r) for(int c = m; 1 <= c; --c) for(int g = 0; g < 2; ++g) for(int d = 0; d < 2; ++d) { maxi(dp[r][c][0][0], dp[r - 1][c + 1][g][d]); if(!(s[r][c] == 'G')) continue; if(in(r - 1, c) && s[r - 1][c] == 'R' && g == 0) if(in(r + 1, c) && s[r + 1][c] == 'W') maxi(dp[r][c][0][1], dp[r - 1][c + 1][g][d] + 1); if(in(r, c + 1) && s[r][c + 1] == 'W' && d == 0) if(in(r, c - 1) && s[r][c - 1] == 'R') maxi(dp[r][c][1][0], dp[r - 1][c + 1][g][d] + 1); } int ans = 0; for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) if(i == n || j == 1) ans += daj(i, j); printf("%d\n", ans); return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
dango_maker.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", s[i] + 1);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...