Submission #99505

# Submission time Handle Problem Language Result Execution time Memory
99505 2019-03-04T12:11:57 Z psmao Dango Maker (JOI18_dango_maker) C++14
0 / 100
3 ms 384 KB
#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] == 'R')
	{
		if(j <= m-2 && a[i][j+1] == 'G' && a[i][j+2] == 'W') ok[i][j][0] = true;
		if(i <= n-2 && a[i+1][j] == 'G' && a[i+2][j] == 'W') ok[i][j][1] = true;
	}
	int ans = 0;
	fo(i,2,n+m) // diagonal
	{
		fo(j,1,i) fo(k,0,2) f[j][k] = 0;
		int last;
		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], max(f[x-1][1], 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

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 time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -