제출 #1113974

#제출 시각아이디문제언어결과실행 시간메모리
1113974ezzzayPlus Minus (BOI17_plusminus)C++14
0 / 100
1 ms2640 KiB
#include<bits/stdc++.h> using namespace std; #define itn long long #define int long long #define ff first #define ss second #define pb push_back const int N=2000; char a[N][N]; const int mod=1e9+7; int dp[N][N][6]; signed main(){ int n,m,k; cin>>n>>m>>k; for(int i=1;i<=k;i++){ char c; int y,x; cin>>c>>y>>x; a[y][x]=c; } for(int j=0;j<=n;j++){ dp[j][0][0]=1; dp[j][0][1]=1; dp[j][0][2]=1; dp[j][5][5]=1; } for(int j=0;j<=m;j++){ dp[0][j][0]=1; dp[0][j][1]=1; dp[0][j][2]=1; dp[0][j][5]=1; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='+'){ dp[i][j][2]=(dp[i-1][j][1]+dp[i-1][j][3])*dp[i][j-1][3]; dp[i][j][4]=(dp[i-1][j][4]+dp[i-1][j][2])*dp[i][j-1][1]; dp[i][j][5]=dp[i-1][j][0]*dp[i][j-1][2]; } else if(a[i][j]=='-'){ dp[i][j][0]=dp[i-1][j][5]*dp[i][j-1][3]; dp[i][j][1]=(dp[i-1][j][1]+dp[i-1][j][3])*dp[i][j-1][4]; dp[i][j][3]=(dp[i-1][j][4]+dp[i-1][j][2])*dp[i][j-1][2]; } else{ dp[i][j][2]=(dp[i-1][j][1]+dp[i-1][j][3])*dp[i][j-1][3]; dp[i][j][4]=(dp[i-1][j][4]+dp[i-1][j][2])*dp[i][j-1][1]; dp[i][j][5]=dp[i-1][j][0]*dp[i][j-1][2]; dp[i][j][0]=dp[i-1][j][5]*dp[i][j-1][3]; dp[i][j][1]=(dp[i-1][j][1]+dp[i-1][j][3])*dp[i][j-1][4]; dp[i][j][3]=(dp[i-1][j][4]+dp[i-1][j][2])*dp[i][j-1][2]; } } } int ans=0; for(int i=0;i<6;i++){ ans+=dp[n][m][i]; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...