답안 #99430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99430 2019-03-04T05:39:22 Z psmao Dango Maker (JOI18_dango_maker) C++14
13 / 100
228 ms 212700 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 = 3005;

int n, m, p[maxn][maxn];
int b[maxn*maxn];
char a[maxn][maxn];
int T, vis[maxn*maxn];
VI adj[maxn*maxn];

void link(int u, int v) {adj[u].pb(v);}
int dfs(int u)
{
	for(auto p : adj[u]) if(vis[p] != T)
	{
		vis[p] = T;
		if(!b[p] || dfs(b[p])) 
		{
			b[p] = u;
			return 1;
		}
	}
	return 0;
}
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);
	int tot = 0;
	fo(i,1,n) fo(j,1,m) p[i][j] = ++ tot;
	fo(i,1,n) fo(j,1,m) if(a[i][j] == 'R')
	{
		if(j+2 <= m && a[i][j+1] == 'G' && a[i][j+2] == 'W')
			link(p[i][j], p[i][j+2]);
		if(i+2 <= n && a[i+1][j] == 'G' && a[i+2][j] == 'W')
			link(p[i][j], p[i+2][j]);
	}
	int ans = 0;
	fo(i,1,n) fo(j,1,m) if(a[i][j] == 'R')
	{
		++ T;
		ans += dfs(p[i][j]);
	} 
	ans = 0;
	fo(i,1,n) fo(j,1,m) if(a[i][j] == 'W' && b[p[i][j]]) ++ ans;
	pf("%d\n",ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:61: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:62: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);
              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 212472 KB Output is correct
2 Correct 206 ms 212484 KB Output is correct
3 Correct 187 ms 212344 KB Output is correct
4 Correct 197 ms 212444 KB Output is correct
5 Correct 201 ms 212560 KB Output is correct
6 Correct 197 ms 212444 KB Output is correct
7 Correct 202 ms 212372 KB Output is correct
8 Correct 211 ms 212572 KB Output is correct
9 Correct 224 ms 212472 KB Output is correct
10 Correct 212 ms 212472 KB Output is correct
11 Correct 200 ms 212600 KB Output is correct
12 Correct 201 ms 212480 KB Output is correct
13 Correct 217 ms 212476 KB Output is correct
14 Correct 196 ms 212472 KB Output is correct
15 Correct 228 ms 212464 KB Output is correct
16 Correct 196 ms 212700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 212472 KB Output is correct
2 Correct 206 ms 212484 KB Output is correct
3 Correct 187 ms 212344 KB Output is correct
4 Correct 197 ms 212444 KB Output is correct
5 Correct 201 ms 212560 KB Output is correct
6 Correct 197 ms 212444 KB Output is correct
7 Correct 202 ms 212372 KB Output is correct
8 Correct 211 ms 212572 KB Output is correct
9 Correct 224 ms 212472 KB Output is correct
10 Correct 212 ms 212472 KB Output is correct
11 Correct 200 ms 212600 KB Output is correct
12 Correct 201 ms 212480 KB Output is correct
13 Correct 217 ms 212476 KB Output is correct
14 Correct 196 ms 212472 KB Output is correct
15 Correct 228 ms 212464 KB Output is correct
16 Correct 196 ms 212700 KB Output is correct
17 Incorrect 195 ms 212424 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 212472 KB Output is correct
2 Correct 206 ms 212484 KB Output is correct
3 Correct 187 ms 212344 KB Output is correct
4 Correct 197 ms 212444 KB Output is correct
5 Correct 201 ms 212560 KB Output is correct
6 Correct 197 ms 212444 KB Output is correct
7 Correct 202 ms 212372 KB Output is correct
8 Correct 211 ms 212572 KB Output is correct
9 Correct 224 ms 212472 KB Output is correct
10 Correct 212 ms 212472 KB Output is correct
11 Correct 200 ms 212600 KB Output is correct
12 Correct 201 ms 212480 KB Output is correct
13 Correct 217 ms 212476 KB Output is correct
14 Correct 196 ms 212472 KB Output is correct
15 Correct 228 ms 212464 KB Output is correct
16 Correct 196 ms 212700 KB Output is correct
17 Incorrect 195 ms 212424 KB Output isn't correct
18 Halted 0 ms 0 KB -