Submission #787272

#TimeUsernameProblemLanguageResultExecution timeMemory
787272guagua0407Dango Maker (JOI18_dango_maker)C++17
0 / 100
4 ms9172 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=3020; int dp[mxn][mxn]; char grid[mxn][mxn]; int main() {_ int n,m; cin>>n>>m; for(int i=0;i<mxn;i++){ fill(grid[i],grid[i]+mxn,'.'); } for(int i=10;i<n+10;i++){ for(int j=10;j<m+10;j++){ cin>>grid[i][j]; } } for(int i=10;i<n+10;i++){ for(int j=10;j<m+10;j++){ dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]; if((grid[i-2][j-2]=='R' and grid[i-2][j-1]=='G' and grid[i-2][j]=='W') and (grid[i-2][j-2]=='R' and grid[i-1][j-2]=='G' and grid[i][j-2]=='W') && (grid[i][j-2]=='W' and grid[i][j-3]=='G' and grid[i][j-4]=='R') and (grid[i-2][j]=='W' and grid[i-3][j]=='G' and grid[i-4][j]=='R')){ dp[i][j]++; } else if((grid[i-1][j-2]=='R' and grid[i-1][j-1]=='G' and grid[i-1][j]=='W') and (grid[i-1][j-2]=='R' and grid[i][j-2]=='G' and grid[i+1][j-2]=='W') && (grid[i][j-1]=='W' and grid[i][j-2]=='G' and grid[i][j-3]=='R') and (grid[i-1][j]=='W' and grid[i-2][j]=='G' and grid[i-3][j]=='R')){ dp[i][j]++; } else if((grid[i-2][j-1]=='R' and grid[i-2][j]=='G' and grid[i-2][j+1]=='W') and (grid[i-2][j-1]=='R' and grid[i-1][j-1]=='G' and grid[i][j-1]=='W') && (grid[i][j-1]=='W' and grid[i][j-2]=='G' and grid[i][j-3]=='R') and (grid[i-1][j]=='W' and grid[i-2][j]=='G' and grid[i-3][j]=='R')){ dp[i][j]++; } if((grid[i][j]=='W' and grid[i][j-1]=='G' and grid[i][j-2]=='R') and (grid[i][j]=='W' and grid[i-1][j]=='G' and grid[i-2][j]=='R')){ dp[i][j]--; } else if((grid[i][j+1]=='W' and grid[i][j]=='G' and grid[i][j-1]=='R') and (grid[i+1][j]=='W' and grid[i][j]=='G' and grid[i-1][j]=='R')){ dp[i][j]--; } if(grid[i][j]=='R' and grid[i][j+1]=='G' and grid[i][j+2]=='W'){ dp[i][j]++; } else if(grid[i][j]=='R' and grid[i+ 1][j]=='G' and grid[i+2][j]=='W'){ dp[i][j]++; } //cout<<dp[i][j]<<' '; } //cout<<'\n'; } cout<<dp[n+9][m+9]<<'\n'; return 0; } //maybe its multiset not set /* 5 5 RGWGR GRGWG GGRGW GGGGG RGWGG */

Compilation message (stderr)

dango_maker.cpp: In function 'void setIO(std::string)':
dango_maker.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...