제출 #892996

#제출 시각아이디문제언어결과실행 시간메모리
892996MinbaevDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; const int mod= 1e9 +7; const int N=1e5*4; void solve(){ int n,m,k; cin>>n>>m; char arr[n+5][n+5]; for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ cin>>arr[i][j]; } } int ans = 0; for(int j = 1;j<=m;j++){ int ind = 1,x = 1,y = j; vector<vector<int>>dp(min(n+1,j+1),{0,0,0}); while(x<=n&&y>=1){ dp[ind][0] = max({dp[ind-1][0],dp[ind-1][1],dp[ind-1][2]}); if(arr[x][y-1]=='R'&&arr[x][y]=='G'&&arr[x][y+1]=='W')dp[ind][1] = max(dp[ind-1][0],dp[ind-1][1]) + 1; if(arr[x-1][y]=='R'&&arr[x][y]=='G'&&arr[x+1][y]=='W')dp[ind][2] = max(dp[ind-1][0],dp[ind-1][2]) + 1; x++;y--;ind++; } ind--; ans += max({dp[ind][0],dp[ind][1],dp[ind][2]}); } for(int i = 2;i<=n;i++){ int ind = 1,x = i,y = m; vector<vector<int>>dp(min(n+1,(m - (i - 1))),{0,0,0}); while(x<=n&&y>=1){ dp[ind][0] = max({dp[ind-1][0],dp[ind-1][1],dp[ind-1][2]}); if(arr[x][y-1]=='R'&&arr[x][y]=='G'&&arr[x][y+1]=='W')dp[ind][1] = max(dp[ind-1][0],dp[ind-1][1]) + 1; if(arr[x-1][y]=='R'&&arr[x][y]=='G'&&arr[x+1][y]=='W')dp[ind][2] = max(dp[ind-1][0],dp[ind-1][2]) + 1; x++;y--;ind++; } ind--; ans += max({dp[ind][0],dp[ind][1],dp[ind][2]}); } cout<<ans<<" "; //ne spizdil , a adaptiroval } signed main() { // freopen("seq.in", "r", stdin); // freopen("seq.out", "w", stdout); ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); int tt=1;//cin>>tt; while(tt--)solve(); }

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'void solve()':
dango_maker.cpp:8:10: warning: unused variable 'k' [-Wunused-variable]
    8 |  int n,m,k;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...