Submission #66885

#TimeUsernameProblemLanguageResultExecution timeMemory
66885hamzqq9Dango Maker (JOI18_dango_maker)C++14
100 / 100
838 ms154684 KiB
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<int,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)>>1) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 100000000000000 #define MOD 1000000007 #define N 3005 #define MAX 10000006 #define LOG 22 using namespace std; int n,m,ans; int dp[N][N][2],node[N][N][2]; char a[N][N]; int main() { //freopen("input.txt","r",stdin); scanf("%d %d",&n,&m); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf(" %c",&a[i][j]); } } // 0 vertical 1 horizontal for(int i=1;i<=n;i++) { if(i>1 && i<n) { for(int j=1;j<=m;j++) { if(a[i-1][j]=='R' && a[i][j]=='G' && a[i+1][j]=='W') node[i][j][0]=1; } } for(int j=2;j<=m;j++) { if(a[i][j-1]=='R' && a[i][j]=='G' && a[i][j+1]=='W') node[i][j][1]=1; } } for(int i=n;i>=1;i--) { for(int j=1;j<=m;j++) { dp[i][j][0]=max(dp[i+1][j-1][1],dp[i+1][j-1][0]+node[i][j][0]); dp[i][j][1]=max(dp[i+1][j-1][0],dp[i+1][j-1][1]+node[i][j][1]); } } for(int i=1;i<=m;i++) ans+=max(dp[1][i][0],dp[1][i][1]); for(int i=2;i<=n;i++) ans+=max(dp[i][m][0],dp[i][m][1]); printf("%d",ans); }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
dango_maker.cpp:38:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...