#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,j,has,te;
char a[3030][3030];
int x[9000010];
int b[3000010];
int mat[3000010];
vector<int> v[3000010];
ll dfs(ll aa)
{
if(b[aa]==i)
return 0;
b[aa]=1;
ll ii;
for(ii=0;ii<v[aa].size();ii++)
if(mat[v[aa][ii]]==-1||dfs(v[aa][ii]))
{
mat[v[aa][ii]]=aa;
return 1;
}
return 0;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
cin>>a[i][j];
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
if(j+2<=m&&a[i][j]=='R'&&a[i][j+1]=='G'&&a[i][j+2]=='W')
{
te++;
has++;
x[(i-1)*m+j]=te;
x[(i-1)*m+j+1]=te;
x[(i-1)*m+j+2]=te;
}
}
ll hai=te;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
if(i+2<=n&&a[i][j]=='R'&&a[i+1][j]=='G'&&a[i+2][j]=='W')
{
te++;
has++;
if(x[(i-1)*m+j]!=0)
{
v[x[(i-1)*m+j]].pb(te);
}
if(x[(i)*m+j]!=0)
{
v[x[(i)*m+j]].pb(te);
}
if(x[(i+1)*m+j]!=0)
{
v[x[(i+1)*m+j]].pb(te);
}
}
}
memset(mat,-1,sizeof(mat));
for(i=1;i<=hai;i++)
{
has-=dfs(i);
}
cout<<has<<"\n";
}
Compilation message
dango_maker.cpp: In function 'll dfs(ll)':
dango_maker.cpp:20:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<v[aa].size();ii++)
~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
82552 KB |
Output is correct |
2 |
Correct |
75 ms |
82680 KB |
Output is correct |
3 |
Correct |
71 ms |
82680 KB |
Output is correct |
4 |
Correct |
72 ms |
82552 KB |
Output is correct |
5 |
Correct |
71 ms |
82552 KB |
Output is correct |
6 |
Correct |
72 ms |
82552 KB |
Output is correct |
7 |
Correct |
72 ms |
82680 KB |
Output is correct |
8 |
Correct |
74 ms |
82548 KB |
Output is correct |
9 |
Correct |
71 ms |
82680 KB |
Output is correct |
10 |
Correct |
75 ms |
82552 KB |
Output is correct |
11 |
Correct |
77 ms |
82552 KB |
Output is correct |
12 |
Correct |
77 ms |
82552 KB |
Output is correct |
13 |
Correct |
75 ms |
82680 KB |
Output is correct |
14 |
Correct |
74 ms |
82556 KB |
Output is correct |
15 |
Correct |
76 ms |
82552 KB |
Output is correct |
16 |
Correct |
76 ms |
82552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
82552 KB |
Output is correct |
2 |
Correct |
75 ms |
82680 KB |
Output is correct |
3 |
Correct |
71 ms |
82680 KB |
Output is correct |
4 |
Correct |
72 ms |
82552 KB |
Output is correct |
5 |
Correct |
71 ms |
82552 KB |
Output is correct |
6 |
Correct |
72 ms |
82552 KB |
Output is correct |
7 |
Correct |
72 ms |
82680 KB |
Output is correct |
8 |
Correct |
74 ms |
82548 KB |
Output is correct |
9 |
Correct |
71 ms |
82680 KB |
Output is correct |
10 |
Correct |
75 ms |
82552 KB |
Output is correct |
11 |
Correct |
77 ms |
82552 KB |
Output is correct |
12 |
Correct |
77 ms |
82552 KB |
Output is correct |
13 |
Correct |
75 ms |
82680 KB |
Output is correct |
14 |
Correct |
74 ms |
82556 KB |
Output is correct |
15 |
Correct |
76 ms |
82552 KB |
Output is correct |
16 |
Correct |
76 ms |
82552 KB |
Output is correct |
17 |
Correct |
71 ms |
82564 KB |
Output is correct |
18 |
Correct |
74 ms |
82524 KB |
Output is correct |
19 |
Correct |
70 ms |
82552 KB |
Output is correct |
20 |
Correct |
74 ms |
82552 KB |
Output is correct |
21 |
Correct |
74 ms |
82544 KB |
Output is correct |
22 |
Correct |
87 ms |
82552 KB |
Output is correct |
23 |
Correct |
75 ms |
82552 KB |
Output is correct |
24 |
Correct |
71 ms |
82552 KB |
Output is correct |
25 |
Correct |
72 ms |
82552 KB |
Output is correct |
26 |
Correct |
70 ms |
82552 KB |
Output is correct |
27 |
Correct |
70 ms |
82528 KB |
Output is correct |
28 |
Correct |
72 ms |
82552 KB |
Output is correct |
29 |
Correct |
76 ms |
82552 KB |
Output is correct |
30 |
Correct |
72 ms |
82680 KB |
Output is correct |
31 |
Correct |
72 ms |
82568 KB |
Output is correct |
32 |
Correct |
71 ms |
82680 KB |
Output is correct |
33 |
Correct |
73 ms |
82680 KB |
Output is correct |
34 |
Correct |
71 ms |
82552 KB |
Output is correct |
35 |
Correct |
71 ms |
82552 KB |
Output is correct |
36 |
Correct |
72 ms |
82552 KB |
Output is correct |
37 |
Correct |
75 ms |
82528 KB |
Output is correct |
38 |
Correct |
84 ms |
82684 KB |
Output is correct |
39 |
Correct |
81 ms |
82552 KB |
Output is correct |
40 |
Correct |
73 ms |
82584 KB |
Output is correct |
41 |
Correct |
72 ms |
82552 KB |
Output is correct |
42 |
Correct |
72 ms |
82560 KB |
Output is correct |
43 |
Correct |
71 ms |
82524 KB |
Output is correct |
44 |
Correct |
71 ms |
82552 KB |
Output is correct |
45 |
Correct |
74 ms |
82680 KB |
Output is correct |
46 |
Correct |
75 ms |
82504 KB |
Output is correct |
47 |
Correct |
75 ms |
82680 KB |
Output is correct |
48 |
Correct |
74 ms |
82640 KB |
Output is correct |
49 |
Correct |
79 ms |
82680 KB |
Output is correct |
50 |
Correct |
72 ms |
82552 KB |
Output is correct |
51 |
Correct |
72 ms |
82524 KB |
Output is correct |
52 |
Correct |
72 ms |
82680 KB |
Output is correct |
53 |
Correct |
72 ms |
82592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
82552 KB |
Output is correct |
2 |
Correct |
75 ms |
82680 KB |
Output is correct |
3 |
Correct |
71 ms |
82680 KB |
Output is correct |
4 |
Correct |
72 ms |
82552 KB |
Output is correct |
5 |
Correct |
71 ms |
82552 KB |
Output is correct |
6 |
Correct |
72 ms |
82552 KB |
Output is correct |
7 |
Correct |
72 ms |
82680 KB |
Output is correct |
8 |
Correct |
74 ms |
82548 KB |
Output is correct |
9 |
Correct |
71 ms |
82680 KB |
Output is correct |
10 |
Correct |
75 ms |
82552 KB |
Output is correct |
11 |
Correct |
77 ms |
82552 KB |
Output is correct |
12 |
Correct |
77 ms |
82552 KB |
Output is correct |
13 |
Correct |
75 ms |
82680 KB |
Output is correct |
14 |
Correct |
74 ms |
82556 KB |
Output is correct |
15 |
Correct |
76 ms |
82552 KB |
Output is correct |
16 |
Correct |
76 ms |
82552 KB |
Output is correct |
17 |
Correct |
71 ms |
82564 KB |
Output is correct |
18 |
Correct |
74 ms |
82524 KB |
Output is correct |
19 |
Correct |
70 ms |
82552 KB |
Output is correct |
20 |
Correct |
74 ms |
82552 KB |
Output is correct |
21 |
Correct |
74 ms |
82544 KB |
Output is correct |
22 |
Correct |
87 ms |
82552 KB |
Output is correct |
23 |
Correct |
75 ms |
82552 KB |
Output is correct |
24 |
Correct |
71 ms |
82552 KB |
Output is correct |
25 |
Correct |
72 ms |
82552 KB |
Output is correct |
26 |
Correct |
70 ms |
82552 KB |
Output is correct |
27 |
Correct |
70 ms |
82528 KB |
Output is correct |
28 |
Correct |
72 ms |
82552 KB |
Output is correct |
29 |
Correct |
76 ms |
82552 KB |
Output is correct |
30 |
Correct |
72 ms |
82680 KB |
Output is correct |
31 |
Correct |
72 ms |
82568 KB |
Output is correct |
32 |
Correct |
71 ms |
82680 KB |
Output is correct |
33 |
Correct |
73 ms |
82680 KB |
Output is correct |
34 |
Correct |
71 ms |
82552 KB |
Output is correct |
35 |
Correct |
71 ms |
82552 KB |
Output is correct |
36 |
Correct |
72 ms |
82552 KB |
Output is correct |
37 |
Correct |
75 ms |
82528 KB |
Output is correct |
38 |
Correct |
84 ms |
82684 KB |
Output is correct |
39 |
Correct |
81 ms |
82552 KB |
Output is correct |
40 |
Correct |
73 ms |
82584 KB |
Output is correct |
41 |
Correct |
72 ms |
82552 KB |
Output is correct |
42 |
Correct |
72 ms |
82560 KB |
Output is correct |
43 |
Correct |
71 ms |
82524 KB |
Output is correct |
44 |
Correct |
71 ms |
82552 KB |
Output is correct |
45 |
Correct |
74 ms |
82680 KB |
Output is correct |
46 |
Correct |
75 ms |
82504 KB |
Output is correct |
47 |
Correct |
75 ms |
82680 KB |
Output is correct |
48 |
Correct |
74 ms |
82640 KB |
Output is correct |
49 |
Correct |
79 ms |
82680 KB |
Output is correct |
50 |
Correct |
72 ms |
82552 KB |
Output is correct |
51 |
Correct |
72 ms |
82524 KB |
Output is correct |
52 |
Correct |
72 ms |
82680 KB |
Output is correct |
53 |
Correct |
72 ms |
82592 KB |
Output is correct |
54 |
Correct |
71 ms |
82568 KB |
Output is correct |
55 |
Correct |
83 ms |
91480 KB |
Output is correct |
56 |
Correct |
78 ms |
82652 KB |
Output is correct |
57 |
Correct |
82 ms |
88568 KB |
Output is correct |
58 |
Correct |
102 ms |
90232 KB |
Output is correct |
59 |
Correct |
341 ms |
132728 KB |
Output is correct |
60 |
Correct |
327 ms |
132728 KB |
Output is correct |
61 |
Correct |
327 ms |
132728 KB |
Output is correct |
62 |
Correct |
71 ms |
82552 KB |
Output is correct |
63 |
Correct |
320 ms |
131448 KB |
Output is correct |
64 |
Runtime error |
1117 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
65 |
Halted |
0 ms |
0 KB |
- |