# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
103046 | 2019-03-28T20:57:50 Z | tincamatei | Dango Maker (JOI18_dango_maker) | C++14 | 215 ms | 211964 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3000; const int MAX_GRAPH = MAX_N * MAX_N; char getch(FILE *fin) { char ch = fgetc(fin); while(!isalpha(ch)) ch = fgetc(fin); return ch; } int top; vector<int> graph[1+MAX_GRAPH]; bool viz[1+MAX_GRAPH]; int edge[MAX_N][MAX_N]; char matr[MAX_N][MAX_N]; void dfs(int nod, int color, int *r) { r[color]++; viz[nod] = true; for(auto it: graph[nod]) if(!viz[it]) dfs(it, 1 - color, r); } int main() { #ifdef HOME FILE *fin = fopen("input.in", "r"); FILE *fout = fopen("output.out", "w"); #else FILE *fin = stdin; FILE *fout = stdout; #endif int n, m; int rez = 0; fscanf(fin, "%d%d", &n, &m); for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) matr[i][j] = getch(fin); for(int i = 0; i < n; ++i) for(int j = 0; j < m - 2; ++j) { if(matr[i][j] == 'R' && matr[i][j + 1] == 'G' && matr[i][j + 2] == 'W') { ++top; edge[i][j] = edge[i][j + 1] = edge[i][j + 2] = top; } } for(int i = 0; i < n - 2; ++i) for(int j = 0; j < m; ++j) { if(matr[i][j] == 'R' && matr[i + 1][j] == 'G' && matr[i + 2][j] == 'W') { ++top; for(int x = 0; x < 3; ++x) if(edge[i + x][j] != 0) { graph[top].push_back(edge[i + x][j]); graph[edge[i + x][j]].push_back(top); } } } for(int i = 1; i <= top; ++i) { if(!viz[i]) { int r[2]; r[0] = r[1] = 0; dfs(i, 0, r); rez = rez + max(r[0], r[1]); } } fprintf(fout, "%d", rez); fclose(fin); fclose(fout); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 211704 KB | Output is correct |
2 | Correct | 192 ms | 211704 KB | Output is correct |
3 | Correct | 194 ms | 211832 KB | Output is correct |
4 | Correct | 190 ms | 211704 KB | Output is correct |
5 | Correct | 181 ms | 211704 KB | Output is correct |
6 | Correct | 193 ms | 211704 KB | Output is correct |
7 | Correct | 184 ms | 211676 KB | Output is correct |
8 | Correct | 185 ms | 211704 KB | Output is correct |
9 | Correct | 195 ms | 211704 KB | Output is correct |
10 | Correct | 190 ms | 211704 KB | Output is correct |
11 | Correct | 186 ms | 211704 KB | Output is correct |
12 | Correct | 191 ms | 211708 KB | Output is correct |
13 | Correct | 187 ms | 211884 KB | Output is correct |
14 | Correct | 180 ms | 211704 KB | Output is correct |
15 | Correct | 186 ms | 211704 KB | Output is correct |
16 | Correct | 193 ms | 211704 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 211704 KB | Output is correct |
2 | Correct | 192 ms | 211704 KB | Output is correct |
3 | Correct | 194 ms | 211832 KB | Output is correct |
4 | Correct | 190 ms | 211704 KB | Output is correct |
5 | Correct | 181 ms | 211704 KB | Output is correct |
6 | Correct | 193 ms | 211704 KB | Output is correct |
7 | Correct | 184 ms | 211676 KB | Output is correct |
8 | Correct | 185 ms | 211704 KB | Output is correct |
9 | Correct | 195 ms | 211704 KB | Output is correct |
10 | Correct | 190 ms | 211704 KB | Output is correct |
11 | Correct | 186 ms | 211704 KB | Output is correct |
12 | Correct | 191 ms | 211708 KB | Output is correct |
13 | Correct | 187 ms | 211884 KB | Output is correct |
14 | Correct | 180 ms | 211704 KB | Output is correct |
15 | Correct | 186 ms | 211704 KB | Output is correct |
16 | Correct | 193 ms | 211704 KB | Output is correct |
17 | Correct | 184 ms | 211676 KB | Output is correct |
18 | Correct | 185 ms | 211704 KB | Output is correct |
19 | Correct | 191 ms | 211676 KB | Output is correct |
20 | Correct | 187 ms | 211800 KB | Output is correct |
21 | Correct | 186 ms | 211704 KB | Output is correct |
22 | Correct | 190 ms | 211832 KB | Output is correct |
23 | Correct | 188 ms | 211792 KB | Output is correct |
24 | Correct | 185 ms | 211676 KB | Output is correct |
25 | Correct | 192 ms | 211704 KB | Output is correct |
26 | Correct | 215 ms | 211704 KB | Output is correct |
27 | Correct | 190 ms | 211792 KB | Output is correct |
28 | Correct | 198 ms | 211704 KB | Output is correct |
29 | Correct | 197 ms | 211704 KB | Output is correct |
30 | Correct | 199 ms | 211636 KB | Output is correct |
31 | Correct | 207 ms | 211692 KB | Output is correct |
32 | Correct | 214 ms | 211704 KB | Output is correct |
33 | Correct | 194 ms | 211932 KB | Output is correct |
34 | Incorrect | 214 ms | 211964 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 211704 KB | Output is correct |
2 | Correct | 192 ms | 211704 KB | Output is correct |
3 | Correct | 194 ms | 211832 KB | Output is correct |
4 | Correct | 190 ms | 211704 KB | Output is correct |
5 | Correct | 181 ms | 211704 KB | Output is correct |
6 | Correct | 193 ms | 211704 KB | Output is correct |
7 | Correct | 184 ms | 211676 KB | Output is correct |
8 | Correct | 185 ms | 211704 KB | Output is correct |
9 | Correct | 195 ms | 211704 KB | Output is correct |
10 | Correct | 190 ms | 211704 KB | Output is correct |
11 | Correct | 186 ms | 211704 KB | Output is correct |
12 | Correct | 191 ms | 211708 KB | Output is correct |
13 | Correct | 187 ms | 211884 KB | Output is correct |
14 | Correct | 180 ms | 211704 KB | Output is correct |
15 | Correct | 186 ms | 211704 KB | Output is correct |
16 | Correct | 193 ms | 211704 KB | Output is correct |
17 | Correct | 184 ms | 211676 KB | Output is correct |
18 | Correct | 185 ms | 211704 KB | Output is correct |
19 | Correct | 191 ms | 211676 KB | Output is correct |
20 | Correct | 187 ms | 211800 KB | Output is correct |
21 | Correct | 186 ms | 211704 KB | Output is correct |
22 | Correct | 190 ms | 211832 KB | Output is correct |
23 | Correct | 188 ms | 211792 KB | Output is correct |
24 | Correct | 185 ms | 211676 KB | Output is correct |
25 | Correct | 192 ms | 211704 KB | Output is correct |
26 | Correct | 215 ms | 211704 KB | Output is correct |
27 | Correct | 190 ms | 211792 KB | Output is correct |
28 | Correct | 198 ms | 211704 KB | Output is correct |
29 | Correct | 197 ms | 211704 KB | Output is correct |
30 | Correct | 199 ms | 211636 KB | Output is correct |
31 | Correct | 207 ms | 211692 KB | Output is correct |
32 | Correct | 214 ms | 211704 KB | Output is correct |
33 | Correct | 194 ms | 211932 KB | Output is correct |
34 | Incorrect | 214 ms | 211964 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |