# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81891 | 2018-10-27T15:20:05 Z | zoooma13 | Dango Maker (JOI18_dango_maker) | C++14 | 2 ms | 696 KB |
#include <bits/stdc++.h> using namespace std; #define MAX_N 3005 int N ,M; char G[MAX_N][MAX_N]; vector <int> Adj[MAX_N]; int idx = 0; int id[MAX_N][MAX_N]; int vis[MAX_N*MAX_N]; int Ev ,Od; void DFS(int Q ,bool S) { Ev += !S ,Od += S; vis[Q] = 1; for(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') id[i][j] = id[i][j+1] = id[i][j+2] = ++idx; int Ans = 0; 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') { if(id[i][j]){ if(id[i+1][j]) Adj[id[i][j]].push_back(id[i+1][j]), Adj[id[i+1][j]].push_back(id[i][j]); if(id[i+2][j]) Adj[id[i][j]].push_back(id[i+2][j]), Adj[id[i+2][j]].push_back(id[i][j]); } else Ans++; } 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 | 376 KB | Output is correct |
2 | Correct | 2 ms | 528 KB | Output is correct |
3 | Correct | 2 ms | 552 KB | Output is correct |
4 | Correct | 2 ms | 552 KB | Output is correct |
5 | Correct | 2 ms | 680 KB | Output is correct |
6 | Incorrect | 2 ms | 696 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 528 KB | Output is correct |
3 | Correct | 2 ms | 552 KB | Output is correct |
4 | Correct | 2 ms | 552 KB | Output is correct |
5 | Correct | 2 ms | 680 KB | Output is correct |
6 | Incorrect | 2 ms | 696 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 528 KB | Output is correct |
3 | Correct | 2 ms | 552 KB | Output is correct |
4 | Correct | 2 ms | 552 KB | Output is correct |
5 | Correct | 2 ms | 680 KB | Output is correct |
6 | Incorrect | 2 ms | 696 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |