제출 #714172

#제출 시각아이디문제언어결과실행 시간메모리
714172089487Dango Maker (JOI18_dango_maker)C++14
0 / 100
1 ms340 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include<bits/stdc++.h> #define int long long #define quick ios::sync_with_stdio(0);cin.tie(0); #define rep(x,a,b) for(int x=a;x<=b;x++) #define repd(x,a,b) for(int x=a;x>=b;x--) #define lowbit(x) (x&-x) #define sz(x) (int)(x.size()) #define F first #define S second #define all(x) x.begin(),x.end() #define mp make_pair #define eb emplace_back using namespace std; typedef pair<int,int> pii; void debug(){ cout<<"\n"; } template <class T,class ... U > void debug(T a, U ... b){ cout<<a<<" ",debug(b...); } const int N=3e3+7; const int INF=1e18; char c[N][N]; int dp[N][3]; signed main(){ quick int n,m; cin>>n>>m; rep(i,1,n){ rep(j,1,m) cin>>c[i][j]; } int ans=0; rep(l,2,n+m){ fill(dp[0],dp[N-1]+3,0); int ret=0; rep(i,1,l-1){ rep(x,0,2){ dp[i][0]=max(dp[i][0],dp[i-1][x]); } int j=l-i; if(j<0||j>m) continue; if(i+1<=n&&i-1>=1&&c[i-1][j]=='R'&&c[i][j]=='G'&&c[i+1][j]=='W'){ dp[i][1]=max(dp[i-1][0],dp[i-1][2])+1; } if(j+1<=m&&j-1>=1&&c[i][j-1]=='R'&&c[i][j]=='G'&&c[i][j+1]=='W'){ dp[i][2]=max(dp[i-1][0],dp[i-1][1])+1; } ret=max({dp[i][0],dp[i][1],dp[i][2],ret}); } ans+=ret; } cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...