Submission #709716

#TimeUsernameProblemLanguageResultExecution timeMemory
709716BaytoroDango Maker (JOI18_dango_maker)C++17
100 / 100
626 ms18076 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const int INF=2e9,mod=1e9+7,N=2e5+10; int dp[3005][5]; char c[3005][3005]; void solve(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>c[i][j]; } } int ans=0; for(int s=2;s<=n+m;s++){ int res=0; for(int i=1;i<=m;i++) dp[i][1]=dp[i][2]=0; for(int i=1;i<=m;i++){ int j=s-i; if(j<1 || j>n) continue; dp[i][1]=max(dp[i-1][1],dp[i-1][2]); if(i>3) dp[i][2]=max(dp[i-1][2],dp[i-3][1]); if(j>2 && c[j-2][i]=='R' && c[j-1][i]=='G' && c[j][i]=='W') dp[i][1]=max(dp[i-1][2],dp[i-1][1])+1; if(i>2 && c[j][i-2]=='R' && c[j][i-1]=='G' && c[j][i]=='W') dp[i][2]=max(dp[i-1][2],dp[i-3][1])+1; res=max(res,max(dp[i][1],dp[i][2])); } ans+=res; } cout<<ans; } main(){ //fopn("cbarn"); //ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); //cout<<endl; } }

Compilation message (stderr)

dango_maker.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
dango_maker.cpp: In function 'void fopn(std::string)':
dango_maker.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...