# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331774 | 2020-11-30T03:11:39 Z | daniel920712 | Dango Maker (JOI18_dango_maker) | C++14 | 35 ms | 47468 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <vector> #include <queue> #include <map> using namespace std; char all[3005][3005]; vector < int > Next[2][1000005]; bool have[2][1000005]={0}; bool is[2][1000005]={0}; int ans=0,a,b; void F(int x,int y) { if(have[x][y]) return ; have[x][y]=1; if(x==0) a++; if(x==1) b++; for(auto i:Next[x][y]) F(1-x,i); } int main() { int N,M,i,j; scanf("%d %d",&N,&M); for(i=0;i<N;i++) scanf("%s",all[i]); for(i=0;i<N;i++) for(j=0;j<M-2;j++) if(all[i][j]=='R'&&all[i][j+1]=='G'&&all[i][j+2]=='W') is[0][i*M+j]=1; for(i=0;i<N-2;i++) for(j=0;j<M;j++) if(all[i][j]=='R'&&all[i+1][j]=='G'&&all[i+2][j]=='W') is[1][i*M+j]=1; for(i=0;i<N;i++) { for(j=0;j<M;j++) { if(is[0][i*M+j]&&is[1][i*M+j]) { Next[0][i*M+j].push_back(i*M+j); Next[1][i*M+j].push_back(i*M+j); } if(is[0][i*M+j]&&i>=1&&j+1<M&&is[1][(i-1)*M+j+1]) { Next[0][i*M+j].push_back((i-1)*M+j+1); Next[1][(i-1)*M+j+1].push_back(i*M+j); } if(is[0][i*M+j]&&i>=2&&j+2<M&&is[1][(i-2)*M+j+2]) { Next[0][i*M+j].push_back((i-2)*M+j+2); Next[1][(i-2)*M+j+2].push_back(i*M+j); } } } for(i=0;i<N*M;i++) { if(is[0][i]&&!have[0][i]) { a=b=0; F(0,i); ans+=max(a,b); } if(is[1][i]&&!have[1][i]) { a=b=0; F(1,i); ans+=max(a,b); } } printf("%d\n",ans); //printf("aa\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 47340 KB | Output is correct |
2 | Correct | 29 ms | 47340 KB | Output is correct |
3 | Correct | 28 ms | 47340 KB | Output is correct |
4 | Correct | 29 ms | 47340 KB | Output is correct |
5 | Correct | 28 ms | 47340 KB | Output is correct |
6 | Correct | 28 ms | 47388 KB | Output is correct |
7 | Correct | 28 ms | 47340 KB | Output is correct |
8 | Correct | 32 ms | 47340 KB | Output is correct |
9 | Correct | 30 ms | 47468 KB | Output is correct |
10 | Correct | 28 ms | 47340 KB | Output is correct |
11 | Correct | 28 ms | 47360 KB | Output is correct |
12 | Correct | 28 ms | 47340 KB | Output is correct |
13 | Correct | 28 ms | 47340 KB | Output is correct |
14 | Correct | 29 ms | 47340 KB | Output is correct |
15 | Correct | 28 ms | 47340 KB | Output is correct |
16 | Correct | 32 ms | 47340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 47340 KB | Output is correct |
2 | Correct | 29 ms | 47340 KB | Output is correct |
3 | Correct | 28 ms | 47340 KB | Output is correct |
4 | Correct | 29 ms | 47340 KB | Output is correct |
5 | Correct | 28 ms | 47340 KB | Output is correct |
6 | Correct | 28 ms | 47388 KB | Output is correct |
7 | Correct | 28 ms | 47340 KB | Output is correct |
8 | Correct | 32 ms | 47340 KB | Output is correct |
9 | Correct | 30 ms | 47468 KB | Output is correct |
10 | Correct | 28 ms | 47340 KB | Output is correct |
11 | Correct | 28 ms | 47360 KB | Output is correct |
12 | Correct | 28 ms | 47340 KB | Output is correct |
13 | Correct | 28 ms | 47340 KB | Output is correct |
14 | Correct | 29 ms | 47340 KB | Output is correct |
15 | Correct | 28 ms | 47340 KB | Output is correct |
16 | Correct | 32 ms | 47340 KB | Output is correct |
17 | Correct | 28 ms | 47340 KB | Output is correct |
18 | Correct | 28 ms | 47340 KB | Output is correct |
19 | Correct | 35 ms | 47340 KB | Output is correct |
20 | Correct | 28 ms | 47340 KB | Output is correct |
21 | Correct | 28 ms | 47340 KB | Output is correct |
22 | Correct | 28 ms | 47340 KB | Output is correct |
23 | Correct | 33 ms | 47272 KB | Output is correct |
24 | Correct | 30 ms | 47340 KB | Output is correct |
25 | Correct | 28 ms | 47340 KB | Output is correct |
26 | Correct | 28 ms | 47288 KB | Output is correct |
27 | Correct | 27 ms | 47340 KB | Output is correct |
28 | Correct | 28 ms | 47340 KB | Output is correct |
29 | Correct | 28 ms | 47340 KB | Output is correct |
30 | Correct | 28 ms | 47320 KB | Output is correct |
31 | Correct | 28 ms | 47340 KB | Output is correct |
32 | Correct | 28 ms | 47360 KB | Output is correct |
33 | Correct | 28 ms | 47340 KB | Output is correct |
34 | Incorrect | 28 ms | 47340 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 47340 KB | Output is correct |
2 | Correct | 29 ms | 47340 KB | Output is correct |
3 | Correct | 28 ms | 47340 KB | Output is correct |
4 | Correct | 29 ms | 47340 KB | Output is correct |
5 | Correct | 28 ms | 47340 KB | Output is correct |
6 | Correct | 28 ms | 47388 KB | Output is correct |
7 | Correct | 28 ms | 47340 KB | Output is correct |
8 | Correct | 32 ms | 47340 KB | Output is correct |
9 | Correct | 30 ms | 47468 KB | Output is correct |
10 | Correct | 28 ms | 47340 KB | Output is correct |
11 | Correct | 28 ms | 47360 KB | Output is correct |
12 | Correct | 28 ms | 47340 KB | Output is correct |
13 | Correct | 28 ms | 47340 KB | Output is correct |
14 | Correct | 29 ms | 47340 KB | Output is correct |
15 | Correct | 28 ms | 47340 KB | Output is correct |
16 | Correct | 32 ms | 47340 KB | Output is correct |
17 | Correct | 28 ms | 47340 KB | Output is correct |
18 | Correct | 28 ms | 47340 KB | Output is correct |
19 | Correct | 35 ms | 47340 KB | Output is correct |
20 | Correct | 28 ms | 47340 KB | Output is correct |
21 | Correct | 28 ms | 47340 KB | Output is correct |
22 | Correct | 28 ms | 47340 KB | Output is correct |
23 | Correct | 33 ms | 47272 KB | Output is correct |
24 | Correct | 30 ms | 47340 KB | Output is correct |
25 | Correct | 28 ms | 47340 KB | Output is correct |
26 | Correct | 28 ms | 47288 KB | Output is correct |
27 | Correct | 27 ms | 47340 KB | Output is correct |
28 | Correct | 28 ms | 47340 KB | Output is correct |
29 | Correct | 28 ms | 47340 KB | Output is correct |
30 | Correct | 28 ms | 47320 KB | Output is correct |
31 | Correct | 28 ms | 47340 KB | Output is correct |
32 | Correct | 28 ms | 47360 KB | Output is correct |
33 | Correct | 28 ms | 47340 KB | Output is correct |
34 | Incorrect | 28 ms | 47340 KB | Output isn't correct |
35 | Halted | 0 ms | 0 KB | - |