QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#465741#3125. Dango Makersnpmrnhlol13 1ms5756kbC++141.6kb2024-07-07 07:16:102024-07-07 07:16:11

Judging History

你现在查看的是最新测评结果

  • [2024-07-07 07:16:11]
  • 评测
  • 测评结果:13
  • 用时:1ms
  • 内存:5756kb
  • [2024-07-07 07:16:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 3e3;
char v[N][N];
bool vis[N][N][2];
int ans = 0;
int n,m;
bool ok(int x,int y,int id){
    if(id == 0){
        return 0 <= x && x <= n - 1 && 0 <= y && y <= m - 3 && (!vis[x][y][id]) && v[x][y] == 'R' && v[x][y + 1] == 'G' && v[x][y + 2] == 'W';
    }else{
        return 0 <= x && x <= n - 3 && 0 <= y && y <= m - 1 && (!vis[x][y][id]) && v[x][y] == 'R' && v[x + 1][y] == 'G' && v[x + 2][y] == 'W';
    }
}
void dfs(int x,int y,int id){
    int cnt0 = 0,cnt1 = 0;
    //cout<<"iteration:\n";
    auto dfs2 = [&](auto self, int x, int y, int id) -> void{
        vis[x][y][id] = 1;
        //cout<<x<<' '<<y<<' '<<id<<'\n';
        if(id == 0){
            cnt0++;
            if(ok(x,y,id^1))self(self, x, y, id^1);
            if(ok(x - 1,y + 1,id^1))self(self, x - 1, y + 1, id^1);
            if(ok(x - 2,y + 2,id^1))self(self, x - 2, y + 2, id^1);
        }else{
            cnt1++;
            if(ok(x,y,id^1))self(self, x, y, id^1);
            if(ok(x + 1,y - 1,id^1))self(self, x + 1, y - 1, id^1);
            if(ok(x + 2,y - 2,id^1))self(self, x + 2, y - 2, id^1);
        }
    };
    dfs2(dfs2, x, y, id);
    ans+=max(cnt0,cnt1);
}
int main(){
    cin>>n>>m;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            cin>>v[i][j];
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            if(ok(i,j,0)){
                dfs(i,j,0);
            }
            if(ok(i,j,1)){
                dfs(i,j,1);
            }
        }
    }
    cout<<ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 13
Accepted

Test #1:

score: 13
Accepted
time: 1ms
memory: 5652kb

input:

1 1
G

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5588kb

input:

1 2
RG

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5728kb

input:

2 1
W
R

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5640kb

input:

3 2
WW
RW
WR

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 1ms
memory: 5652kb

input:

4 4
GRRW
GWWR
WWWW
RGRG

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 5580kb

input:

4 4
RGRR
RRRG
GRGW
RGWW

output:

2

result:

ok single line: '2'

Test #7:

score: 0
Accepted
time: 0ms
memory: 5608kb

input:

4 4
RRGR
GRRG
WRGW
RGWW

output:

3

result:

ok single line: '3'

Test #8:

score: 0
Accepted
time: 0ms
memory: 5668kb

input:

4 4
RGWR
GGGW
WWGW
RWGW

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 5596kb

input:

3 3
RGW
GGG
WGW

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 5680kb

input:

4 1
W
R
G
W

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 0ms
memory: 5660kb

input:

4 4
RGWR
GWRG
WRGW
RGWR

output:

3

result:

ok single line: '3'

Test #12:

score: 0
Accepted
time: 1ms
memory: 5532kb

input:

4 4
RWWR
GWRG
WGGW
RGWR

output:

3

result:

ok single line: '3'

Test #13:

score: 0
Accepted
time: 1ms
memory: 5712kb

input:

4 4
RGWR
WWRG
WRGW
RWGR

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 1ms
memory: 5580kb

input:

4 4
RRRR
GGGG
WWWW
RRRR

output:

4

result:

ok single line: '4'

Test #15:

score: 0
Accepted
time: 1ms
memory: 5672kb

input:

4 4
RRRR
GGGR
WWWW
RRRR

output:

3

result:

ok single line: '3'

Test #16:

score: 0
Accepted
time: 1ms
memory: 5728kb

input:

4 4
RRRR
GGGG
WWWW
RWRR

output:

4

result:

ok single line: '4'

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #17:

score: 20
Accepted
time: 1ms
memory: 5660kb

input:

5 5
RRGRR
RGRGW
RRWRW
RGWGW
RWWWW

output:

3

result:

ok single line: '3'

Test #18:

score: 0
Accepted
time: 1ms
memory: 5552kb

input:

6 6
RGWRGW
RRRGWR
RRWGWR
WRRRWG
GGGGGW
WWWWWW

output:

7

result:

ok single line: '7'

Test #19:

score: 0
Accepted
time: 1ms
memory: 5756kb

input:

7 10
RRRGRGWRGW
RGGGWRRGWR
RWWWWGRRGG
RGWRWWGGGW
WWRGWRGWGW
RGWWGGRGWW
RRGWWWWWWW

output:

14

result:

ok single line: '14'

Test #20:

score: 0
Accepted
time: 1ms
memory: 5684kb

input:

10 8
RGWRRRGW
RGWGRRGW
WRGWGRGW
RGWWRGWW
GWRRGWWW
WRRGRWRR
GRGWGRGG
WGWWWRWR
RGWRGRGW
RRWRGWWW

output:

16

result:

ok single line: '16'

Test #21:

score: 0
Accepted
time: 0ms
memory: 5684kb

input:

10 10
RRRRGWRRGW
GRGRGRGGRR
RGRGWGRRGR
RWWWRRGRGW
GRGGGRGWGG
WRGWWGGRGW
GGGRWWWRRR
WWGRGWRRGG
WWGWGWGGWW
RRGWGRWWWW

output:

16

result:

ok single line: '16'

Test #22:

score: 0
Accepted
time: 0ms
memory: 5616kb

input:

10 10
RRRWRGWRGW
GGGGGGRRWG
WGWRWWGGGW
RRRRRRWRRG
GGGGGGRGGR
WGWWWWGWGW
WRRGWRWRGW
RGWGRGWGRW
GRWRGWWWGG
RGWWGWRGWW

output:

19

result:

ok single line: '19'

Test #23:

score: 0
Accepted
time: 1ms
memory: 5600kb

input:

10 10
WGWGRWWGWR
RGGWGRWWGR
GWRRRRWWWG
RGWRGWRRRG
GRRWWGGRGG
GGGGRWGRGG
RRRGWWWWRW
WRRRWRGRGR
RGWGRWGRWG
WRRWGGGWWW

output:

7

result:

ok single line: '7'

Test #24:

score: 0
Accepted
time: 0ms
memory: 5728kb

input:

10 10
GGRRGRGRWR
RRWRGWWRRW
WGRWWRRRWG
GGWWRWGRGR
RGGGRRGWRR
WRWWWRWWWW
WRWGGGGRRR
RWGRGRWGGW
GWGWWGWGRR
GRWGGGWRWW

output:

2

result:

ok single line: '2'

Test #25:

score: 0
Accepted
time: 0ms
memory: 5640kb

input:

10 1
R
G
R
W
G
G
G
R
G
R

output:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 0ms
memory: 5652kb

input:

1 10
GGGRWWGGWW

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 0ms
memory: 5688kb

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRRWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

27

result:

ok single line: '27'

Test #28:

score: 0
Accepted
time: 1ms
memory: 5576kb

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRWWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRWWRGWRG
RRGWRGWRGW
RGWRGWRGWW

output:

26

result:

ok single line: '26'

Test #29:

score: 0
Accepted
time: 1ms
memory: 5684kb

input:

10 10
RGGRGWGGWR
GGRGWRWWRG
WRGWRGWRGW
GGWGWWRGWR
RWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWWGWRGRRG
WRGWRGGRGW
RGWRGRRGWR

output:

20

result:

ok single line: '20'

Test #30:

score: 0
Accepted
time: 1ms
memory: 5660kb

input:

10 10
RRRRRRRRRR
GGWGGGGGGG
WWWWWWWWWW
RRRRRRRRRR
GGGGGGGGGG
WWWWWWWGWW
RRRRRRRRRR
GGGGGGGGGG
WWWWWWWWWW
RRRRRRRRRR

output:

28

result:

ok single line: '28'

Test #31:

score: 0
Accepted
time: 1ms
memory: 5552kb

input:

10 10
RRGRRRWRRR
GGGGGGGGRG
WWWGWWWWWW
RRRRRRRRRR
GGGGGGGGGG
WGRWWWWWWW
RRRRRRRRRR
GGGGGGGGGG
WWWWWWWWWW
RRRRRRRRRR

output:

24

result:

ok single line: '24'

Test #32:

score: 0
Accepted
time: 0ms
memory: 5736kb

input:

10 10
RGRRRRRGRR
GGGGWGGGGG
GWWWWWWRWW
RRRRWRRRRR
GGGGGGGGGG
WWWWWWWWRW
RRRRRRRRRR
GGGGGWGGGG
GWGWWWWGWW
RWRRRRRRWW

output:

20

result:

ok single line: '20'

Test #33:

score: 0
Accepted
time: 1ms
memory: 5684kb

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGGRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

26

result:

ok single line: '26'

Test #34:

score: -20
Wrong Answer
time: 1ms
memory: 5748kb

input:

10 10
RGWRGWRGWR
WWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWWGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

26

result:

wrong answer 1st lines differ - expected: '27', found: '26'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%