Submission #892918

#TimeUsernameProblemLanguageResultExecution timeMemory
892918ReLiceDango Maker (JOI18_dango_maker)C++14
100 / 100
266 ms110924 KiB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool flag=false;
    if(x>y){
        x=y;flag|=true;
    }
    return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag=false;
    if (x<y){
        x=y;flag|=true;
    }
    return flag;
}
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e9+7;
const ll mod=1e9+7;
const ll N=3e3+5;
const ld eps=1e-9;
char a[N][N];
void solve(){
	ll i,j;
	ll n,m;
	cin>>n>>m;
	vector<vll> dio(n+m+5);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
			dio[i+j].pb(i);
		}
	}
	ll res=0;
	for(i=2;i<=n+m;i++){
		ll dp[dio[i].sz+5][3];
		memset(dp,0ll,sizeof(dp));
		for(j=1;j<=(ll)dio[i].sz;j++){
			ll x=dio[i][j-1],y=i-dio[i][j-1];
			dp[j][0]=max({dp[j-1][0],dp[j-1][1],dp[j-1][2]});
			if(a[x-1][y]=='R' && a[x][y]=='G' && a[x+1][y]=='W')dp[j][1]=max(dp[j-1][1],dp[j-1][0])+1;
			if(a[x][y-1]=='R' && a[x][y]=='G' && a[x][y+1]=='W')dp[j][2]=max(dp[j-1][2],dp[j-1][0])+1;
		}
		res+=max({dp[dio[i].sz][0],dp[dio[i].sz][1],dp[dio[i].sz][2]});
	}
	cout<<res<<endl;
}
// this time i wrote it myself but nothing really changed XD
signed main(){
	start();
    ll t=1;
	//cin>>t;
    while(t--) solve();
    return 0;
}
/*






*/

Compilation message (stderr)

dango_maker.cpp: In function 'void fre(std::string)':
dango_maker.cpp:42:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:42:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...