제출 #201345

#제출 시각아이디문제언어결과실행 시간메모리
201345abilDango Maker (JOI18_dango_maker)C++14
13 / 100
6 ms504 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define sz(s) s.size() #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (3e3 + 12); const int mod = (1e9 + 7); const int inf = (1e9 + 7); int dp[N][N], cnt[N][N]; char a[N][N]; main(){ int n, m; scanf("%d%d", &n, &m); for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ scanf(" %c", &a[i][j]); } } for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ int x = 0, y = 0; if(j >= 3){ if(a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R'){ y++; } } if(i >= 3){ if(a[i][j] == 'W' && a[i - 1][j] == 'G' && a[i - 2][j] == 'R'){ x++; } } if((dp[i - 1][j] + x + dp[i][j - 1] - dp[i - 1][j - 1]) >= (dp[i][j - 1] + y + dp[i - 1][j] - dp[i - 1][j - 1])){ dp[i][j] = (dp[i - 1][j] + x + dp[i][j - 1]) - dp[i - 1][j - 1]; if(x){ cnt[i][j]--; cnt[i - 1][j]--; cnt[i - 2][j]--; } } else{ dp[i][j] = (dp[i][j - 1] + y + dp[i - 1][j]) - dp[i - 1][j - 1]; if(y){ cnt[i][j]--; cnt[i][j - 1]--; cnt[i][j - 2]--; } } } } for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ if(cnt[i][j] < 0){ dp[n][m] += cnt[i][j] + 1; } } } cout << dp[n][m]; }

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

dango_maker.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:21: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:24: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...