# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81899 | 2018-10-27T15:50:57 Z | zoooma13 | Dango Maker (JOI18_dango_maker) | C++14 | 3 ms | 1020 KB |
#include <bits/stdc++.h> using namespace std; #define MAX_N 3005 int N ,M; char G[MAX_N][MAX_N]; set <int> Adj[MAX_N]; int idx = 0; int id1[MAX_N][MAX_N]; int id2[MAX_N][MAX_N]; bool vis[MAX_N*MAX_N]; int Ev ,Od; void DFS(int Q ,bool S) { Ev += !S ,Od += S; vis[Q] = 1; for(const int&i : Adj[Q]) if(!vis[i]) DFS(i ,!S); } int main() { scanf("%d%d",&N,&M); for(int i=0; i<N; i++) scanf("%s",G[i]); for(int i=0; i<N; i++) for(int j=0; j<M-2; j++) if(G[i][j] == 'R' && G[i][j+1] == 'G' && G[i][j+2] == 'W') id1[i][j] = id1[i][j+1] = id1[i][j+2] = ++idx; for(int i=0; i<N-2; i++) for(int j=0; j<M; j++) if(G[i][j] == 'R' && G[i+1][j] == 'G' && G[i+2][j] == 'W') id2[i][j] = id2[i+1][j] = id2[i+2][j] = ++idx; for(int i=0; i<N; i++) for(int j=0; j<M; j++) if(id1[i][j] != id2[i][j] && min(id1[i][j] ,id2[i][j]) != 0) { Adj[id1[i][j]].insert(id2[i][j]); Adj[id2[i][j]].insert(id1[i][j]); } int Ans = 0; for(int i=1; i<=idx; i++) { Ev = 0 ,Od = 0; if(!vis[i]) DFS(i ,0); Ans += max(Ev ,Od); } printf("%d\n",Ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 580 KB | Output is correct |
3 | Correct | 3 ms | 580 KB | Output is correct |
4 | Correct | 2 ms | 580 KB | Output is correct |
5 | Correct | 2 ms | 736 KB | Output is correct |
6 | Correct | 3 ms | 736 KB | Output is correct |
7 | Correct | 2 ms | 736 KB | Output is correct |
8 | Correct | 2 ms | 736 KB | Output is correct |
9 | Correct | 2 ms | 808 KB | Output is correct |
10 | Correct | 2 ms | 808 KB | Output is correct |
11 | Correct | 2 ms | 808 KB | Output is correct |
12 | Correct | 3 ms | 808 KB | Output is correct |
13 | Correct | 2 ms | 808 KB | Output is correct |
14 | Correct | 3 ms | 808 KB | Output is correct |
15 | Correct | 2 ms | 808 KB | Output is correct |
16 | Correct | 2 ms | 808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 580 KB | Output is correct |
3 | Correct | 3 ms | 580 KB | Output is correct |
4 | Correct | 2 ms | 580 KB | Output is correct |
5 | Correct | 2 ms | 736 KB | Output is correct |
6 | Correct | 3 ms | 736 KB | Output is correct |
7 | Correct | 2 ms | 736 KB | Output is correct |
8 | Correct | 2 ms | 736 KB | Output is correct |
9 | Correct | 2 ms | 808 KB | Output is correct |
10 | Correct | 2 ms | 808 KB | Output is correct |
11 | Correct | 2 ms | 808 KB | Output is correct |
12 | Correct | 3 ms | 808 KB | Output is correct |
13 | Correct | 2 ms | 808 KB | Output is correct |
14 | Correct | 3 ms | 808 KB | Output is correct |
15 | Correct | 2 ms | 808 KB | Output is correct |
16 | Correct | 2 ms | 808 KB | Output is correct |
17 | Correct | 3 ms | 808 KB | Output is correct |
18 | Correct | 3 ms | 912 KB | Output is correct |
19 | Correct | 2 ms | 912 KB | Output is correct |
20 | Correct | 3 ms | 912 KB | Output is correct |
21 | Correct | 3 ms | 912 KB | Output is correct |
22 | Correct | 2 ms | 912 KB | Output is correct |
23 | Correct | 3 ms | 912 KB | Output is correct |
24 | Correct | 2 ms | 912 KB | Output is correct |
25 | Correct | 3 ms | 912 KB | Output is correct |
26 | Correct | 3 ms | 912 KB | Output is correct |
27 | Correct | 3 ms | 976 KB | Output is correct |
28 | Correct | 2 ms | 996 KB | Output is correct |
29 | Correct | 3 ms | 1000 KB | Output is correct |
30 | Correct | 2 ms | 1000 KB | Output is correct |
31 | Correct | 3 ms | 1000 KB | Output is correct |
32 | Correct | 2 ms | 1000 KB | Output is correct |
33 | Correct | 3 ms | 1016 KB | Output is correct |
34 | Incorrect | 2 ms | 1020 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 580 KB | Output is correct |
3 | Correct | 3 ms | 580 KB | Output is correct |
4 | Correct | 2 ms | 580 KB | Output is correct |
5 | Correct | 2 ms | 736 KB | Output is correct |
6 | Correct | 3 ms | 736 KB | Output is correct |
7 | Correct | 2 ms | 736 KB | Output is correct |
8 | Correct | 2 ms | 736 KB | Output is correct |
9 | Correct | 2 ms | 808 KB | Output is correct |
10 | Correct | 2 ms | 808 KB | Output is correct |
11 | Correct | 2 ms | 808 KB | Output is correct |
12 | Correct | 3 ms | 808 KB | Output is correct |
13 | Correct | 2 ms | 808 KB | Output is correct |
14 | Correct | 3 ms | 808 KB | Output is correct |
15 | Correct | 2 ms | 808 KB | Output is correct |
16 | Correct | 2 ms | 808 KB | Output is correct |
17 | Correct | 3 ms | 808 KB | Output is correct |
18 | Correct | 3 ms | 912 KB | Output is correct |
19 | Correct | 2 ms | 912 KB | Output is correct |
20 | Correct | 3 ms | 912 KB | Output is correct |
21 | Correct | 3 ms | 912 KB | Output is correct |
22 | Correct | 2 ms | 912 KB | Output is correct |
23 | Correct | 3 ms | 912 KB | Output is correct |
24 | Correct | 2 ms | 912 KB | Output is correct |
25 | Correct | 3 ms | 912 KB | Output is correct |
26 | Correct | 3 ms | 912 KB | Output is correct |
27 | Correct | 3 ms | 976 KB | Output is correct |
28 | Correct | 2 ms | 996 KB | Output is correct |
29 | Correct | 3 ms | 1000 KB | Output is correct |
30 | Correct | 2 ms | 1000 KB | Output is correct |
31 | Correct | 3 ms | 1000 KB | Output is correct |
32 | Correct | 2 ms | 1000 KB | Output is correct |
33 | Correct | 3 ms | 1016 KB | Output is correct |
34 | Incorrect | 2 ms | 1020 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |