Submission #199742

#TimeUsernameProblemLanguageResultExecution timeMemory
199742MercenaryDango Maker (JOI18_dango_maker)C++14
33 / 100
243 ms10336 KiB
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; const int maxn = 3e3 + 5; int dp[maxn][3]; int n , m; string s[maxn]; bool Up(int i , int j){ return i > 0 && i + 1 < m && s[i][j] == 'G' && s[i - 1][j] == 'R' && s[i + 1][j] == 'W'; } bool Rig(int i , int j){ return j > 0 && j + 1 < n && s[i][j] == 'G' && s[i][j - 1] == 'R' && s[i][j + 1] == 'W'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> m >> n; for(int i = 0 ; i < m ; ++i)cin >> s[i]; int res = 0; for(int dia = 0 ; dia <= m + n - 2 ; ++dia){ int tmp = 0; int L = max(0,dia-n+1);int R = min(m,dia+1); for(int i = L ; i < R ; ++i){ if(i == L){ dp[i][0] = dp[i][1] = dp[i][2] = 0; if(Up(i,dia-i))dp[i][1] = 1; if(Rig(i,dia-i))dp[i][2] = 1; tmp = max(dp[i][1],dp[i][2]); }else{ dp[i][0] = max({dp[i - 1][0] , dp[i - 1][1] , dp[i - 1][2]}); if(Up(i,dia-i))dp[i][1] = max(dp[i - 1][0] , dp[i - 1][1]) + 1; else dp[i][1] = 0; if(Rig(i,dia-i))dp[i][2] = max(dp[i - 1][0] , dp[i - 1][2]) + 1; else dp[i][2] = 0; tmp = max({tmp , dp[i][0] , dp[i][1] , dp[i][2]}); } // cout << dia << " " << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl; } res += tmp; } cout << res; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...