# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64108 | 2018-08-03T11:11:51 Z | patrikpavic2 | Dango Maker (JOI18_dango_maker) | C++17 | 87 ms | 78564 KB |
#include <cstdio> #include <vector> using namespace std; const int N = 1e3 + 50; const int M = 2 * N * N; vector < int > v[M], k[N][N]; int ty[M], sl[M], bio[M]; char s[N][N]; int n, m; void dfs(int x){ sl[ty[x]]++; bio[x] = 1; for(int y : v[x]) if(!bio[y]) dfs(y); } int main(){ scanf("%d%d", &n, &m); for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ scanf(" %c", &s[i][j]); } } int cnt = 1; for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ if(s[i][j] != 'G') continue; if(s[i - 1][j] == 'R' && s[i + 1][j] == 'W'){ k[i - 1][j].push_back(cnt); k[i + 1][j].push_back(cnt); k[i][j].push_back(cnt); cnt++; } if(s[i][j - 1] == 'R' && s[i][j + 1] == 'W'){ k[i][j - 1].push_back(cnt); k[i][j + 1].push_back(cnt); k[i][j].push_back(cnt); ty[cnt] = 1; cnt++; } } } for(int i = 1;i<=n;i++){ for(int j = 1;j<=m;j++){ if(k[i][j].size() == 2){ v[k[i][j][0]].push_back(k[i][j][1]); v[k[i][j][1]].push_back(k[i][j][0]); } } } int sol = 0; //printf("CNT = %d\n", cnt); for(int i = 1;i<cnt;i++){ if(bio[i]) continue; sl[0] = 0, sl[1] = 0; dfs(i); //printf("X : %d, %d %d\n", sl[0], sl[1]); sol += max(sl[0], sl[1]); } printf("%d\n", sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 79 ms | 77944 KB | Output is correct |
2 | Correct | 76 ms | 78052 KB | Output is correct |
3 | Correct | 75 ms | 78128 KB | Output is correct |
4 | Correct | 79 ms | 78204 KB | Output is correct |
5 | Correct | 67 ms | 78204 KB | Output is correct |
6 | Correct | 64 ms | 78204 KB | Output is correct |
7 | Correct | 66 ms | 78204 KB | Output is correct |
8 | Correct | 65 ms | 78204 KB | Output is correct |
9 | Correct | 71 ms | 78204 KB | Output is correct |
10 | Correct | 66 ms | 78204 KB | Output is correct |
11 | Correct | 65 ms | 78204 KB | Output is correct |
12 | Correct | 64 ms | 78204 KB | Output is correct |
13 | Correct | 74 ms | 78204 KB | Output is correct |
14 | Correct | 74 ms | 78204 KB | Output is correct |
15 | Correct | 67 ms | 78304 KB | Output is correct |
16 | Correct | 77 ms | 78304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 79 ms | 77944 KB | Output is correct |
2 | Correct | 76 ms | 78052 KB | Output is correct |
3 | Correct | 75 ms | 78128 KB | Output is correct |
4 | Correct | 79 ms | 78204 KB | Output is correct |
5 | Correct | 67 ms | 78204 KB | Output is correct |
6 | Correct | 64 ms | 78204 KB | Output is correct |
7 | Correct | 66 ms | 78204 KB | Output is correct |
8 | Correct | 65 ms | 78204 KB | Output is correct |
9 | Correct | 71 ms | 78204 KB | Output is correct |
10 | Correct | 66 ms | 78204 KB | Output is correct |
11 | Correct | 65 ms | 78204 KB | Output is correct |
12 | Correct | 64 ms | 78204 KB | Output is correct |
13 | Correct | 74 ms | 78204 KB | Output is correct |
14 | Correct | 74 ms | 78204 KB | Output is correct |
15 | Correct | 67 ms | 78304 KB | Output is correct |
16 | Correct | 77 ms | 78304 KB | Output is correct |
17 | Correct | 70 ms | 78304 KB | Output is correct |
18 | Correct | 79 ms | 78304 KB | Output is correct |
19 | Correct | 81 ms | 78328 KB | Output is correct |
20 | Correct | 82 ms | 78328 KB | Output is correct |
21 | Correct | 79 ms | 78328 KB | Output is correct |
22 | Correct | 74 ms | 78352 KB | Output is correct |
23 | Correct | 87 ms | 78564 KB | Output is correct |
24 | Correct | 79 ms | 78564 KB | Output is correct |
25 | Correct | 79 ms | 78564 KB | Output is correct |
26 | Correct | 78 ms | 78564 KB | Output is correct |
27 | Correct | 83 ms | 78564 KB | Output is correct |
28 | Correct | 74 ms | 78564 KB | Output is correct |
29 | Correct | 81 ms | 78564 KB | Output is correct |
30 | Correct | 81 ms | 78564 KB | Output is correct |
31 | Correct | 81 ms | 78564 KB | Output is correct |
32 | Correct | 71 ms | 78564 KB | Output is correct |
33 | Correct | 67 ms | 78564 KB | Output is correct |
34 | Incorrect | 70 ms | 78564 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 79 ms | 77944 KB | Output is correct |
2 | Correct | 76 ms | 78052 KB | Output is correct |
3 | Correct | 75 ms | 78128 KB | Output is correct |
4 | Correct | 79 ms | 78204 KB | Output is correct |
5 | Correct | 67 ms | 78204 KB | Output is correct |
6 | Correct | 64 ms | 78204 KB | Output is correct |
7 | Correct | 66 ms | 78204 KB | Output is correct |
8 | Correct | 65 ms | 78204 KB | Output is correct |
9 | Correct | 71 ms | 78204 KB | Output is correct |
10 | Correct | 66 ms | 78204 KB | Output is correct |
11 | Correct | 65 ms | 78204 KB | Output is correct |
12 | Correct | 64 ms | 78204 KB | Output is correct |
13 | Correct | 74 ms | 78204 KB | Output is correct |
14 | Correct | 74 ms | 78204 KB | Output is correct |
15 | Correct | 67 ms | 78304 KB | Output is correct |
16 | Correct | 77 ms | 78304 KB | Output is correct |
17 | Correct | 70 ms | 78304 KB | Output is correct |
18 | Correct | 79 ms | 78304 KB | Output is correct |
19 | Correct | 81 ms | 78328 KB | Output is correct |
20 | Correct | 82 ms | 78328 KB | Output is correct |
21 | Correct | 79 ms | 78328 KB | Output is correct |
22 | Correct | 74 ms | 78352 KB | Output is correct |
23 | Correct | 87 ms | 78564 KB | Output is correct |
24 | Correct | 79 ms | 78564 KB | Output is correct |
25 | Correct | 79 ms | 78564 KB | Output is correct |
26 | Correct | 78 ms | 78564 KB | Output is correct |
27 | Correct | 83 ms | 78564 KB | Output is correct |
28 | Correct | 74 ms | 78564 KB | Output is correct |
29 | Correct | 81 ms | 78564 KB | Output is correct |
30 | Correct | 81 ms | 78564 KB | Output is correct |
31 | Correct | 81 ms | 78564 KB | Output is correct |
32 | Correct | 71 ms | 78564 KB | Output is correct |
33 | Correct | 67 ms | 78564 KB | Output is correct |
34 | Incorrect | 70 ms | 78564 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |