# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
709716 | Baytoro | Dango Maker (JOI18_dango_maker) | C++17 | 626 ms | 18076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |