QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196662#3125. Dango MakerCamillus100 ✓374ms12512kbC++202.5kb2023-10-01 21:12:342023-10-01 21:12:35

Judging History

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

  • [2023-10-01 21:12:35]
  • 评测
  • 测评结果:100
  • 用时:374ms
  • 内存:12512kb
  • [2023-10-01 21:12:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

char t[3003][3003];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif
    int n, m;
    cin >> n >> m;
    int ans = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> t[i][j];        
        }
    }

    for (int a = 1; a <= n; a++) {
        int x = a;
        int y = 1;

        vector<int> s;
        while (1 <= x && x <= n && 1 <= y && y <= m) {
            s.emplace_back(0);
            if (t[x][y - 1] == 'R' && t[x][y] == 'G' && t[x][y + 1] == 'W') {
                s.back() |= 1;
            }
            if (t[x - 1][y] == 'R' && t[x][y] == 'G' && t[x + 1][y] == 'W') {
                s.back() |= 2;
            }
            x--, y++;
        }
        vector<vector<int>> dp(s.size(), vector<int>(3));
        
        dp[0][1] = bool(s[0] & 1);
        dp[0][2] = bool(s[0] & 2);

        for (int i = 1; i < s.size(); i++) {
            dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
            if (s[i] & 1) {
                dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + 1;
            }
            if (s[i] & 2) {
                dp[i][2] = max(dp[i - 1][2], dp[i - 1][0]) + 1;
            }
        }

        ans += *max_element(dp.back().begin(), dp.back().end());
    }

    for (int b = 2; b <= m; b++) {
        int x = n;
        int y = b;

        vector<int> s;
        while (1 <= x && x <= n && 1 <= y && y <= m) {
            s.emplace_back(0);
            if (t[x][y - 1] == 'R' && t[x][y] == 'G' && t[x][y + 1] == 'W') {
                s.back() |= 1;
            }
            if (t[x - 1][y] == 'R' && t[x][y] == 'G' && t[x + 1][y] == 'W') {
                s.back() |= 2;
            }
            x--, y++;
        }
        vector<vector<int>> dp(s.size(), vector<int>(3));
        
        dp[0][1] = bool(s[0] & 1);
        dp[0][2] = bool(s[0] & 2);

        for (int i = 1; i < s.size(); i++) {
            dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
            if (s[i] & 1) {
                dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + 1;
            }
            if (s[i] & 2) {
                dp[i][2] = max(dp[i - 1][2], dp[i - 1][0]) + 1;
            }
        }

        ans += *max_element(dp.back().begin(), dp.back().end());
    }

    cout << ans << '\n';
    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: 3476kb

input:

1 1
G

output:

0

result:

ok single line: '0'

Test #2:

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

input:

1 2
RG

output:

0

result:

ok single line: '0'

Test #3:

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

input:

2 1
W
R

output:

0

result:

ok single line: '0'

Test #4:

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

input:

3 2
WW
RW
WR

output:

0

result:

ok single line: '0'

Test #5:

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

input:

4 4
GRRW
GWWR
WWWW
RGRG

output:

0

result:

ok single line: '0'

Test #6:

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

input:

4 4
RGRR
RRRG
GRGW
RGWW

output:

2

result:

ok single line: '2'

Test #7:

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

input:

4 4
RRGR
GRRG
WRGW
RGWW

output:

3

result:

ok single line: '3'

Test #8:

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

input:

4 4
RGWR
GGGW
WWGW
RWGW

output:

1

result:

ok single line: '1'

Test #9:

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

input:

3 3
RGW
GGG
WGW

output:

1

result:

ok single line: '1'

Test #10:

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

input:

4 1
W
R
G
W

output:

1

result:

ok single line: '1'

Test #11:

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

input:

4 4
RGWR
GWRG
WRGW
RGWR

output:

3

result:

ok single line: '3'

Test #12:

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

input:

4 4
RWWR
GWRG
WGGW
RGWR

output:

3

result:

ok single line: '3'

Test #13:

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

input:

4 4
RGWR
WWRG
WRGW
RWGR

output:

2

result:

ok single line: '2'

Test #14:

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

input:

4 4
RRRR
GGGG
WWWW
RRRR

output:

4

result:

ok single line: '4'

Test #15:

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

input:

4 4
RRRR
GGGR
WWWW
RRRR

output:

3

result:

ok single line: '3'

Test #16:

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

input:

4 4
RRRR
GGGG
WWWW
RWRR

output:

4

result:

ok single line: '4'

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #17:

score: 20
Accepted
time: 0ms
memory: 3428kb

input:

5 5
RRGRR
RGRGW
RRWRW
RGWGW
RWWWW

output:

3

result:

ok single line: '3'

Test #18:

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

input:

6 6
RGWRGW
RRRGWR
RRWGWR
WRRRWG
GGGGGW
WWWWWW

output:

7

result:

ok single line: '7'

Test #19:

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

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: 3468kb

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: 3516kb

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: 1ms
memory: 3504kb

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: 0ms
memory: 3444kb

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: 3460kb

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: 1ms
memory: 3444kb

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: 3504kb

input:

1 10
GGGRWWGGWW

output:

0

result:

ok single line: '0'

Test #27:

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

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: 0ms
memory: 3472kb

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: 0ms
memory: 3452kb

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: 0ms
memory: 3440kb

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: 0ms
memory: 3476kb

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: 1ms
memory: 3504kb

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: 3504kb

input:

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

output:

26

result:

ok single line: '26'

Test #34:

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

input:

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

output:

27

result:

ok single line: '27'

Test #35:

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

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRWWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWWGW
RGWRGWRGWR
GWRGWRGWGG
WRGWRGWRGW
RGWRGWRGWR

output:

27

result:

ok single line: '27'

Test #36:

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

input:

10 10
RGWRGWRGWR
GWRRWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGG
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

26

result:

ok single line: '26'

Test #37:

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

input:

10 10
RGWRWWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRWWRGWRG
WRGWRGWRGW
RGWRRWRGWR
GWRGWRGWRG
RRGWRGWRGW
RGWRGWRGWR

output:

26

result:

ok single line: '26'

Test #38:

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

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRWWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRWWRGRRG
WRGWRGWRGW
RGWRGWRGWW

output:

26

result:

ok single line: '26'

Test #39:

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

input:

10 10
RGWRGWGGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
RWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWWGWRGWRG
WRGWRGGRGW
RGWRGRRGWR

output:

24

result:

ok single line: '24'

Test #40:

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

input:

10 10
RGGRGWRGWR
GGRGWRWWRG
WRGWRGWRGW
GGWGGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

25

result:

ok single line: '25'

Test #41:

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

input:

10 10
RGGRGWRGWR
GWWGWRGWRG
WRGGRGWRGW
RGWRGWRGWR
GWRGWGGWRG
WGRWRGWGGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

25

result:

ok single line: '25'

Test #42:

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

input:

10 10
RGWRGWWGWR
GWGGWRGWRG
GRGWRGWRGW
RGWRGWRRWR
GWRGGRGWRG
WRRWRGWRGW
RGWRGWRGWR
GWRGWRGWRG
WRGWRWWRGW
RGWRGWRGWR

output:

24

result:

ok single line: '24'

Test #43:

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

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRWWRGWR
GWRGWRGGRG
WRGWRGWRGW
RGWRGWRGWR
GWRGWWGWRG
GRGWRGWGGW
RWWRGWRGWR

output:

25

result:

ok single line: '25'

Test #44:

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

input:

10 10
RGWRGWRGWR
GWRGWRGWRG
WRWWRRGRWW
RGWRGWWGWR
GWRWWRGWRG
WRGWRGWRRW
RGWRGWRGWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWW

output:

25

result:

ok single line: '25'

Test #45:

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

input:

10 10
RGWRGWRGWR
GWRGRRGWRW
WRGWRGWRGW
RGWRGWRGWR
GRRGWRGWRG
GRGWRGWRGG
RGWRGRRGWR
WWRGWRGWRG
WRGWRGWRGW
RGWRGWRGWR

output:

24

result:

ok single line: '24'

Test #46:

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

input:

10 10
RGWRGWRGWR
GWGGWRGWRG
RRGWRRWRGW
RGWRGWRRWR
GWRGWRGWRG
WRGWRGWRGW
RGWRGWRGGR
GWRGWRRWRR
WRGWRGWRGW
RGWRGWRGWR

output:

25

result:

ok single line: '25'

Test #47:

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

input:

10 10
RWWRGWRGWR
GWRGWRGWRG
WRGWGGWRGW
RGWRGWRGWR
GWRGWWGGRG
WRGWWGWRGW
RGWRGWRGWR
GWRGWRGGRW
WRRWRGWRGW
WGWRGWWGWR

output:

21

result:

ok single line: '21'

Test #48:

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

input:

10 10
RGWRGWRGWR
GWGGWGGWWG
WRGWRGWRRW
RGGRWWRGWR
GWRRWRGWWG
WRGWRWWRGW
WGWRGWRGWR
GWRGWRGWWG
WWGWRGWRGW
RGRRGWRGWR

output:

20

result:

ok single line: '20'

Test #49:

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

input:

10 10
RRWRGWRGWR
GWRGWRGWRG
WRGWRGWRWW
RGWRRWRWWR
GWGGWRGWRG
WRGWWGWRGW
RGWRGWRWWR
GWRGWRGWRG
WWGWRGWRGW
RGGRGWRGWW

output:

22

result:

ok single line: '22'

Test #50:

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

input:

10 10
RGWRWWRGWR
GWRGWRGWRG
WRGRRGWRGW
RGWRGWRGRR
GWRGWRGWRG
WRGWRGWRGW
RGGRGWGGWR
GWRGWRGWRG
RRGRWGWWGW
RGWRGWRGWR

output:

22

result:

ok single line: '22'

Test #51:

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

input:

10 10
RGWRGWRGGR
GWRGWRWWWG
WRGRWGWRRW
RGWRGWRGWR
GWGGWRGWRR
WRGWRGGRGW
RGWRGWRGWR
GRRGWRGWRG
RRGWRGWRGW
RGWRGGRGWR

output:

21

result:

ok single line: '21'

Test #52:

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

input:

10 10
RGWRGWRGWR
GRRGWRGWRR
WRGWRGWWGW
RGWRGWRRWR
RWRRWRGWRW
WRGWRGWRGG
RGWRGWRGWR
GWRGWRRWRG
WRGWRGWRGW
RWWRGWRGWR

output:

24

result:

ok single line: '24'

Test #53:

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

input:

10 10
RWRRGWRGWR
RWRGGRGWRG
WRGWRGWGGW
RGWWGWRGWR
WWRGWRWRRG
WRGRRGWRGW
RGWRWWRGWW
GWRGWRGWRG
WRGWGGWRGW
RGWRGWRGWR

output:

22

result:

ok single line: '22'

Subtask #3:

score: 67
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #54:

score: 67
Accepted
time: 1ms
memory: 3488kb

input:

1 3000
WRGRGRWRRRWGGRWGGWRRRRWWGGGRRRGGGGRRRWRRGRGRGWWRWRWRRWRGGWWWGRRGRGWWGRWRWWGGGWGWRWRWGGRRGRGRRRRWWGWWWGRRRWGRRGWRWGGWGWRRGRWRGWGWWGGWWRRGWGGWGRWWGGWGGGRRGGRRRGWRWGGRWRRWRGRGRWRGGRGGRRRRRGGRRGGGGWWWRGGRRWWRWGWGRRWGWGGWRRGGRWWRGGRRGRGRWRWGRGGWGWWWWWWGWGRRWGGRGGGGGWGGRRRGWRWGWRWGGRGGWGGWGRWWGWRRG...

output:

115

result:

ok single line: '115'

Test #55:

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

input:

3000 1
W
W
W
R
R
R
G
W
R
W
R
G
G
G
W
G
G
G
R
G
R
G
G
G
G
R
G
W
G
R
G
W
R
G
R
G
R
W
R
R
R
R
W
R
R
W
G
R
G
R
R
G
G
R
W
R
W
R
W
W
R
W
G
R
G
R
G
W
G
G
G
R
W
R
W
W
W
R
R
W
G
R
G
G
W
G
R
G
G
G
G
G
G
W
G
R
W
W
W
G
G
R
R
R
G
R
R
W
W
W
R
W
W
G
R
R
R
W
G
R
W
W
R
W
W
R
W
R
R
G
W
R
R
W
W
R
R
R
R
W
G
R
R
W
R
G
G...

output:

103

result:

ok single line: '103'

Test #56:

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

input:

5 3000
GRGGRRWGWWRRWGWRRGWRGWWRWRRGWRRGRWRRRGWGGRWRRRRWRRRRGWGWGRGWRRRRRWWWRRWRRGWGWRRWRRRRRRRWRRGRWRGRGRGRRRWRRGRRGWRRGWRGRWRRGWRGWWRGWWRGRRGRRGWRRGWWGRWRGWRRRGWWRRWWGGRRGRGWWGRRGWRRGWRRWGRRGRGWRRGWWRGWRRRWRWWRRRWRRGWWGWRRGWGWWRRGWWWRGWRGWRRWWRRRRRGRGRGWRGWWRGRGRRGWWRRGRGWRGRGWRRRGWGGGRGWRGWRGWRRGW...

output:

2477

result:

ok single line: '2477'

Test #57:

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

input:

2000 8
RWRGWRGW
GRGRGGGG
WGRGWWRR
GWWWRRGW
GRRGRGRR
RGWWGWGR
RWRGRGWW
RGRRGWWG
RRGWWGWG
GGGWGRGW
RWWWRGRR
RRGRGWGW
RRGGWWGR
RRGWWWWW
GRGWRRRW
RRGWRGWW
RGGRWGWW
GWWWGWGW
GRGWRRGW
GRGRGWGW
RRRGRGWW
GRGWWRGW
RGWRGRWW
WRGRRGWW
GRRGWWRG
RGRWRGRW
RWRWGRGG
GRRRWGWR
WGRRGWWG
WRGWGRRW
RRGWRGWR
GWWRGWWG
RGWWW...

output:

2616

result:

ok single line: '2616'

Test #58:

score: 0
Accepted
time: 44ms
memory: 8344kb

input:

1000 1000
WGRWGRRGRGWRWWWWWGWRGRGWGGRRRWGRGRGWGWGRWWGWWRRRRWWRRRRWGGGWGRWRRGGRRRRWRWGWGWRRWGGGRRRRRRWRWGWGGGRRGWRWWWWWRRRWGGRGGWGGRGRWWRWGGGGWRWWWWWWWWGGGWWGGWWRWWWGWRRRGGRWWWWGGGRWGWGRRGRGRGWRRGWGRWWGGWRWWGGGWGRRRRWRWRWRRWRWRWGRGGWGGGWGRRGRWGWWRGGGRWWGGGGWRGGGRWGGWGWWWWGWWGGWGRGGGRWRWRRRGRRGGRGWRRR...

output:

69578

result:

ok single line: '69578'

Test #59:

score: 0
Accepted
time: 351ms
memory: 12404kb

input:

3000 3000
RWRWRWWGRRWGWGWGWRGGRWRGRGWGGRRRRWRRWWGRGWRRRWGGRWWGRGWWGGGWRGWRGGGRRWWRRGGGWGGWRGWWWRRWRGGRRRWGGWWWGRGGRRGWRRRGWGWWWGGWGGRGGWRWWWRWGRWGRWRRWGRRGWWWGRWGRWGGGGWWGGRRRGWGRRWRGGWGGGGRGGGRWGWRRRRWWRRRRWWGRGRWRGRRWGGRGWRWGGWRWWGRGRRRGRWWGRWRGGWGRWWGGWRGWWRRGWGWRGWRWGGRWGGRWWWGWGWRGRGGWRGWRGRWRR...

output:

580652

result:

ok single line: '580652'

Test #60:

score: 0
Accepted
time: 366ms
memory: 12448kb

input:

3000 3000
RRRGRRGGGGWRRWRWGGRWRRWWGRGGRWRWWGGWRGGGWRRRRWGRWWRWWWWRRWWWGGRWGGRRGRGRRWWWRWWGRRGGGWRRRRGRWWWGRWGRRGRGGRWRWRWWGWGGWRWWRRWWRGGRGWRGRGWRRWGGWGRGWWRWGRWRWRGWRRRGRRGGWGGRRWGRGRWGGGWGRWRRWRWGWGWGGRWWGGGRWRRRRWWWWRGWGRWGRWWRRWWWWWRRRWGWWWWWWWRWGRRGRRGWWGRGGGRWRWRWWRWRGGWGRGWRGWRGGGWGWWWWGGWGWG...

output:

580629

result:

ok single line: '580629'

Test #61:

score: 0
Accepted
time: 374ms
memory: 12444kb

input:

3000 3000
GGRWGGGRGGGGGWGGRRRRGGRRRWWRRWWWRGRWWWGWWRWWRWGRRGWRRRGGGRRWRGGWWGRRWGWGGGGWRRWRRGGRRRGGGRWGWGWRRWGGWGGWRGGWRWRWGWRWRRWGWRGRGWRGGGRWGWRWGGRWWRWRGRWWGGGRWGGGWGGRRRWWGGGRRRGGGWGWWGRRWGGGRGWWRGRWRGRGGRRWWRRWRWWRGRWRWRWGRRRGRRWRGWGGWWWWGWWWGWGGWWRWWWGWGWGGRGWRWWWGRWWGRWRWGGGGRRWRGGWWGGWWWRWGGG...

output:

579341

result:

ok single line: '579341'

Test #62:

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

input:

2 2808
RGWWRGRRGWGRRGWGWRRWGRRGWGWWGGRGRGRRRWRRRWRRRGWRGRWGWGGWWRWRWWWWWGWGRGWRWGWGRWGWWGRRRRWRRGGRGWWRRWWRRGWWGGGGGRRGRWWWGRRRGWWRWRWWGWWWRWWWRWRRGGGWWRGGRWRRGWRWGGRGGRRWWWWWWWRWGGWWGGGRRGWRRRRWGGWWWRGGGRWRWWWGWWGWRRWRWGWWGGGGGRWWWWWWWWRWRGWGWWRRGGWRWRRGRWRWGRGRGGWRWGWWGRWRWRWWGRRWRRWGGWGRGRRGGGRWW...

output:

202

result:

ok single line: '202'

Test #63:

score: 0
Accepted
time: 368ms
memory: 12392kb

input:

3000 2900
GRGGRGGRGRWGRRWGRRGWWWRWWGWRRGWWGGGGWWWRGGWRWWGRRRRGGRGGRGGGWRWGWGWRGRWRRGRGGWGRGGWRWWRWRWGWGGWRGRWWRWWRWGGWGRRGGGGWRRWWGWRGGGWRWGRRRRWRRRWGWWRGGWGGRRRRRRGGWWRRRGGWWRGGRGGWGRGWWRRGWGWWWWRGRWRWWGGRGWGGWGWWWWRGWWWWWRWRGGGGGGGRGGWWGWWRWGWWGWRRWGWRGWWWGRRGRRGWWWWWWRGRRRGGWGRGGWWWRGWRGGWGGRGWWR...

output:

561374

result:

ok single line: '561374'

Test #64:

score: 0
Accepted
time: 333ms
memory: 12512kb

input:

3000 3000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

2997980

result:

ok single line: '2997980'

Test #65:

score: 0
Accepted
time: 336ms
memory: 12504kb

input:

3000 3000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

2997680

result:

ok single line: '2997680'

Test #66:

score: 0
Accepted
time: 341ms
memory: 12512kb

input:

3000 3000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

2992937

result:

ok single line: '2992937'

Test #67:

score: 0
Accepted
time: 301ms
memory: 12356kb

input:

3000 3000
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

2996636

result:

ok single line: '2996636'

Test #68:

score: 0
Accepted
time: 307ms
memory: 12404kb

input:

3000 3000
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

2966932

result:

ok single line: '2966932'

Test #69:

score: 0
Accepted
time: 312ms
memory: 12504kb

input:

3000 3000
RRRRRRRRRRRRRRRRRRRRRGRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRGRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRWRRRRRRRRGRGRRRRRRRRRRRRRRRRRRRRRGRRRRRRRRRRRRRRRRRRRRRRRRWRRRRRRWRRRRRRRRRRRRRRRRRGRRRRRRRRR...

output:

2687330

result:

ok single line: '2687330'

Test #70:

score: 0
Accepted
time: 35ms
memory: 7920kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332639

result:

ok single line: '332639'

Test #71:

score: 0
Accepted
time: 38ms
memory: 7748kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332620

result:

ok single line: '332620'

Test #72:

score: 0
Accepted
time: 39ms
memory: 6732kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332582

result:

ok single line: '332582'

Test #73:

score: 0
Accepted
time: 40ms
memory: 7636kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332548

result:

ok single line: '332548'

Test #74:

score: 0
Accepted
time: 39ms
memory: 8032kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332503

result:

ok single line: '332503'

Test #75:

score: 0
Accepted
time: 48ms
memory: 7016kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332486

result:

ok single line: '332486'

Test #76:

score: 0
Accepted
time: 40ms
memory: 7016kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332415

result:

ok single line: '332415'

Test #77:

score: 0
Accepted
time: 39ms
memory: 7396kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRRWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332378

result:

ok single line: '332378'

Test #78:

score: 0
Accepted
time: 39ms
memory: 7308kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332349

result:

ok single line: '332349'

Test #79:

score: 0
Accepted
time: 35ms
memory: 8084kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332321

result:

ok single line: '332321'

Test #80:

score: 0
Accepted
time: 40ms
memory: 8068kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332260

result:

ok single line: '332260'

Test #81:

score: 0
Accepted
time: 36ms
memory: 6960kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332193

result:

ok single line: '332193'

Test #82:

score: 0
Accepted
time: 35ms
memory: 7156kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRRWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332162

result:

ok single line: '332162'

Test #83:

score: 0
Accepted
time: 36ms
memory: 8252kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWGGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332095

result:

ok single line: '332095'

Test #84:

score: 0
Accepted
time: 35ms
memory: 8072kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332084

result:

ok single line: '332084'

Test #85:

score: 0
Accepted
time: 40ms
memory: 7780kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

332003

result:

ok single line: '332003'

Test #86:

score: 0
Accepted
time: 39ms
memory: 7628kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

331924

result:

ok single line: '331924'

Test #87:

score: 0
Accepted
time: 36ms
memory: 6936kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

331870

result:

ok single line: '331870'

Test #88:

score: 0
Accepted
time: 35ms
memory: 7940kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

331836

result:

ok single line: '331836'

Test #89:

score: 0
Accepted
time: 37ms
memory: 7728kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

331742

result:

ok single line: '331742'

Test #90:

score: 0
Accepted
time: 35ms
memory: 6444kb

input:

1000 1000
RGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRGWRG...

output:

331681

result:

ok single line: '331681'

Extra Test:

score: 0
Extra Test Passed