Submission #99508

#TimeUsernameProblemLanguageResultExecution timeMemory
99508psmaoDango Maker (JOI18_dango_maker)C++14
100 / 100
242 ms27384 KiB
#include <bits/stdc++.h> using namespace std; #define fo(i,s,t) for(int i = s; i <= t; ++ i) #define fd(i,s,t) for(int i = s; i >= t; -- i) #define bf(i,s) for(int i = head[s]; i; i = e[i].next) #define mp make_pair #define fi first #define se second #define pii pair<int,int> #define pb push_back #define VI vector<int> #define sf scanf #define pf printf #define fp freopen #define SZ(x) ((int)(x).size()) #ifdef MPS #define D(x...) printf(x) #else #define D(x...) #endif typedef long long ll; typedef double db; typedef unsigned long long ull; const int inf = 1<<30; const ll INF = 1ll<<60; const db Inf = 1e20; const db eps = 1e-9; void gmax(int &a,int b){a = (a > b ? a : b);} void gmin(int &a,int b){a = (a < b ? a : b);} const int maxn = 3050; int n, m, f[maxn][3]; char a[maxn][maxn]; bool ok[maxn][maxn][2]; int main() { #ifdef MPS fp("1.in","r",stdin); fp("1.out","w",stdout); #endif sf("%d%d",&n,&m); fo(i,1,n) sf("%s",a[i]+1); fo(i,1,n) fo(j,1,m) if(a[i][j] == 'G') { if(a[i][j-1] == 'R' && a[i][j+1] == 'W') ok[i][j][0] = true; if(a[i-1][j] == 'R' && a[i+1][j] == 'W') ok[i][j][1] = true; } int ans = 0; fo(i,2,n+m) // diagonal { fo(j,1,min(n,i)) fo(k,0,2) f[j][k] = 0; int last = 0; for(int x = 1, y = i - 1; x <= n; ++ x, -- y) { if(y < 1 || y > m) continue; // out of the grid f[x][0] = max(max(f[x-1][0], f[x-1][1]), f[x-1][2]); if(ok[x][y][0]) // we have a horizontal one here f[x][1] = max(f[x-1][0], f[x-1][1]) + 1; if(ok[x][y][1]) f[x][2] = max(f[x-1][0], f[x-1][2]) + 1; last = x; } ans += max(f[last][0], max(f[last][1], f[last][2])); } pf("%d\n",ans); return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:45:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d%d",&n,&m);
    ^
dango_maker.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,n) sf("%s",a[i]+1);
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...