Submission #1018048

#TimeUsernameProblemLanguageResultExecution timeMemory
1018048phongDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms4444 KiB
#include<bits/stdc++.h> #define ll long long #define int long long const int nmax = 3000 + 5, N = 4e5; const ll oo = 1e9; const int lg = 18, M = 4e3; const int base = 2e5, mod = 1e9 + 7; #define pii pair<int, int> #define fi first #define se second #define endl "\n" #define debug(a, n) for(int i = 1; i <= n; ++i) cout << a[i] << ' ';cout << endl using namespace std; const double eps = 1e-9; int n, m; char a[nmax][nmax]; vector<pii> adj[nmax * 2]; int dp[nmax][nmax][3]; bool ok(int i, int j, int id){ if(id == 1){ return a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W'; } else{ return a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W'; } } main(){ cin >> n>> m; for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ cin >> a[i][j]; adj[i + j].push_back({i, j}); } } for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]}); dp[i][j][1] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][2] + ok(i, j, 1)); dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1] + ok(i, j, 2)); } } int ans = 0; for(int i = 2; i <= n + m; ++i){ int x = adj[i].back().fi; int y = adj[i].back().se; ans += max({dp[x][y][0], dp[x][y][1],dp[x][y][2]}); } cout << ans; }

Compilation message (stderr)

dango_maker.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...