Submission #814983

#TimeUsernameProblemLanguageResultExecution timeMemory
814983trucmaiDango Maker (JOI18_dango_maker)C++17
100 / 100
274 ms226176 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "/home/trucmai/.vim/tools.h" #define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define debug(x...) #endif void open(){ if(fopen("i.inp","r")){ freopen("i.inp","r",stdin); freopen("o.out","w",stdout); } } #define ll int #define all(a) (a).begin(), (a).end() #define vi vector<ll> #define pi pair<ll,ll> #define pii pair<ll,pair<ll,ll>> #define fi first #define se second #define gcd __gcd #define mset(a,v) memset(a, v, sizeof(a)) #define endl '\n' #define spc " " const int MN = 3001,LOG = 27; const ll MOD = 1e9 + 7,INF = 1e9; ll n,m,dp[MN][MN][3],dango[MN][MN][3]; char a[MN][MN]; void solve(){ cin>>n>>m; for(ll i = 1;i <= n;++i) for(ll j = 1;j <= m;++j) cin>>a[i][j]; for(ll i = 1;i <= n;++i) for(ll j = 1;j <= m;++j){ if(a[i-1][j] == 'R' && a[i][j] == 'G' && a[i+1][j] == 'W') dango[i][j][1] = 1; if(a[i][j-1] == 'R' && a[i][j] == 'G' && a[i][j+1] == 'W') dango[i][j][2] = 1; } for(ll i = 1;i <= n;++i){ for(ll j = 1;j <= m;++j){ dp[i][j][0] += max({dp[i-1][j+1][0],dp[i-1][j+1][1],dp[i-1][j+1][2]}); dp[i][j][1] += max({dp[i-1][j+1][0],dp[i-1][j+1][1]}) + dango[i][j][1]; dp[i][j][2] += max({dp[i-1][j+1][0],dp[i-1][j+1][2]}) + dango[i][j][2]; } } ll res = 0; for(ll i = 1;i <= n;++i) res += max({dp[i][1][0],dp[i][1][1],dp[i][1][2]}); for(ll i = 2;i <= m;++i) res += max({dp[n][i][0],dp[n][i][1],dp[n][i][2]}); cout<<res<<endl; } signed main(){ cin.tie(0) -> sync_with_stdio(0); open(); ll t = 1; //cin>>t; while(t--) solve(); cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; }

Compilation message (stderr)

dango_maker.cpp: In function 'void open()':
dango_maker.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("i.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
dango_maker.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("o.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...