Submission #210004

#TimeUsernameProblemLanguageResultExecution timeMemory
210004kshitij_sodaniDango Maker (JOI18_dango_maker)C++17
100 / 100
498 ms44536 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef int64_t llo; #define a first #define b second #define endl "\n" int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; int it[n][m]; char s; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>s; if(s=='R'){ it[i][j]=0; } else if(s=='G'){ it[i][j]=1; } else{ it[i][j]=2; } } } int tot=0; for(int ii=0;ii<n+m-1;ii++){ vector<pair<int,int>> aa; for(int jj=0;jj<ii+1;jj++){ int i,j; j=jj; i=ii-j; int co=0; int co2=0; if(i>=n or j>=m){ continue; } int st=1; int stt=1; if(j>0 and it[i][j-1]==0 and j+1<m and it[i][j+1]==2 and it[i][j]==1){ co+=1; } if(i>0 and i+1<n and it[i-1][j]==0 and it[i+1][j]==2 and it[i][j]==1){ co2+=1; } aa.pb({co,co2}); } pair<int,int> dp[aa.size()]; dp[0]=aa[0]; for(int k=1;k<aa.size();k++){ dp[k]=dp[k-1]; if(aa[k].a==1){ dp[k].a+=1; if(k>1){ dp[k].a=max(dp[k].a,dp[k-2].b+1); } } if(aa[k].b==1){ dp[k].b+=1; if(k>1){ dp[k].b=max(dp[k].b,dp[k-2].a+1); } } } tot+=max(dp[aa.size()-1].a,dp[aa.size()-1].b); } cout<<tot<<endl; return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:45:8: warning: unused variable 'st' [-Wunused-variable]
    int st=1;
        ^~
dango_maker.cpp:46:8: warning: unused variable 'stt' [-Wunused-variable]
    int stt=1;
        ^~~
dango_maker.cpp:58:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<aa.size();k++){
               ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...