Submission #1262178

#TimeUsernameProblemLanguageResultExecution timeMemory
1262178Bui_Quoc_CuongDango Maker (JOI18_dango_maker)C++20
100 / 100
134 ms9292 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a;i<=(int)b;i++) #define FORD(i,a,b) for(int i=a;i>=(int)b;i--) #define fi first #define se second #define pb push_back #define ALL(A) A.begin(), A.end() #define BIT(mask,i) ((mask>>(i))&1) template <class A, class B> bool maximize(A &a, const B b) {if(a<b){a = b;return 1;} return 0;} template <class A, class B> bool minimize(A &a, const B b) {if(a>b){a = b;return 1;} return 0;} int n,m; char a[3005][3005]; void init() { cin >> n >> m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin >> a[i][j]; } } } void process() { int ans = 0; for(int c = 1; c <= n + m; c++) { vector <int> f1(m + 6, 0); vector <int> f2(m + 6, 0); int mx = 0; for(int j = min(m, c - 1), i = c - j; j >= 1 && i <= n; j--, i++) { f1[j] = max(f1[j + 1], f2[j + 3]) + (a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W'); f2[j] = max(f1[j + 1], f2[j + 1]) + (a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W'); maximize(mx, max(f1[j], f2[j])); } ans+= mx; } cout << ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); #define Hori "dango" if(fopen(Hori".inp", "r")) { freopen(Hori".inp", "r", stdin); freopen(Hori".out", "w", stdout); } init(); process(); return 0; } /* 3 4 RGWR GRGG RGWW */

Compilation message (stderr)

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