QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#192542#3125. Dango MakerCamillus#33 952ms209560kbC++203.7kb2023-09-30 14:48:362024-07-04 02:49:06

Judging History

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

  • [2024-07-04 02:49:06]
  • 评测
  • 测评结果:33
  • 用时:952ms
  • 内存:209560kb
  • [2023-09-30 14:48:36]
  • 提交

answer

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

char t[3000][3000];

int S = 0;
int T = 1;
int cnt_vertexes = 2;

map<pair<int, int>, int> saved_input_vertexes;
int get_input_vertex(int i, int j) {
    if (!saved_input_vertexes.contains(make_pair(i, j))) {
        saved_input_vertexes[make_pair(i, j)] = cnt_vertexes++;
    }
    return saved_input_vertexes[make_pair(i, j)];
}

map<pair<int, int>, int> saved_output_vertexes;
int get_output_vertex(int i, int j) {
    if (!saved_output_vertexes.contains(make_pair(i, j))) {
        saved_output_vertexes[make_pair(i, j)] = cnt_vertexes++;
    }
    return saved_output_vertexes[make_pair(i, j)];
}

map<pair<int, int>, int> saved_vertexes;
int get_vertex(int i, int j) {
    if (!saved_vertexes.contains(make_pair(i, j))) {
        saved_vertexes[make_pair(i, j)] = cnt_vertexes++;
    }
    return saved_vertexes[make_pair(i, j)];
}

struct Edge {
    int to, f, c;
};

Edge edges[3'000'000];
int cnt_edges = 0;

vector<int> g[10'000'000];

void add_edge(int u, int v, int w) {
    edges[cnt_edges] = Edge{v, 0, w};
    g[u].push_back(cnt_edges);
    cnt_edges++;
    edges[cnt_edges] = Edge{u, 0, 0};
    g[v].push_back(cnt_edges);
    cnt_edges++;
}

int dist[10'000'000];
int p[10'000'000];

bool bfs() {
    memset(dist, 1, sizeof(int) * cnt_vertexes);
    int inf = dist[S];
    dist[S] = 0;
    deque<int> Q = {S};
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop_front();
        for (int e_i : g[u]) {
            auto& [v, f, c] = edges[e_i];
            if (f < c && dist[v] > dist[u] + 1) {
                dist[v] = dist[u] + 1;
                Q.push_back(v);
            }
        }
    }
    return dist[T] != inf;
}

int dfs(int u, int flow = INT32_MAX) {
    if (u == T) {
        return flow;
    }
    for (; p[u] < g[u].size(); p[u]++) {
        int e_i = g[u][p[u]];
        auto& [v, f, c] = edges[e_i];
        if (f < c && dist[v] == dist[u] + 1) {
            int res = dfs(v, min(flow, c - f));
            if (res) {
                edges[e_i].f += res;
                edges[e_i ^ 1].f -= res;
                return res;
            }
        }
    }
    return 0;
}

int dinic() {
    int ans = 0;
    while (bfs()) {
        memset(p, 0, sizeof(int) * cnt_vertexes);
        while (int res = dfs(S)) {
            ans += res;
        }
    }
    return ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> t[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (t[i][j] == 'R') {
                add_edge(S, get_vertex(i, j), 1);
            }
            if (t[i][j] == 'W') {
                add_edge(get_vertex(i, j), T, 1);
            }
            if (t[i][j] == 'G') {
                add_edge(get_input_vertex(i, j), get_output_vertex(i, j), 1);
            }
            if (i + 2 < n && t[i][j] == 'R' && t[i + 1][j] == 'G' && t[i + 2][j] == 'W') {
                add_edge(get_vertex(i, j), get_input_vertex(i + 1, j), 1);
                add_edge(get_output_vertex(i + 1, j), get_vertex(i + 2, j), 1);
            }
            if (j + 2 < m && t[i][j] == 'R' && t[i][j + 1] == 'G' && t[i][j + 2] == 'W') {
                add_edge(get_vertex(i, j), get_input_vertex(i, j + 1), 1);
                add_edge(get_output_vertex(i, j + 1), get_vertex(i, j + 2), 1);
            }
        }
    }

    cout << dinic() << '\n';
    return 0;
}

詳細信息

Subtask #1:

score: 13
Accepted

Test #1:

score: 13
Accepted
time: 9ms
memory: 7656kb

input:

1 1
G

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 9ms
memory: 7712kb

input:

1 2
RG

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 9ms
memory: 7820kb

input:

2 1
W
R

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 9ms
memory: 7660kb

input:

3 2
WW
RW
WR

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 6ms
memory: 8008kb

input:

4 4
GRRW
GWWR
WWWW
RGRG

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 9ms
memory: 8016kb

input:

4 4
RGRR
RRRG
GRGW
RGWW

output:

2

result:

ok single line: '2'

Test #7:

score: 0
Accepted
time: 9ms
memory: 7724kb

input:

4 4
RRGR
GRRG
WRGW
RGWW

output:

3

result:

ok single line: '3'

Test #8:

score: 0
Accepted
time: 6ms
memory: 7724kb

input:

4 4
RGWR
GGGW
WWGW
RWGW

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 6ms
memory: 7756kb

input:

3 3
RGW
GGG
WGW

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 4ms
memory: 7952kb

input:

4 1
W
R
G
W

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 6ms
memory: 7600kb

input:

4 4
RGWR
GWRG
WRGW
RGWR

output:

3

result:

ok single line: '3'

Test #12:

score: 0
Accepted
time: 9ms
memory: 7600kb

input:

4 4
RWWR
GWRG
WGGW
RGWR

output:

3

result:

ok single line: '3'

Test #13:

score: 0
Accepted
time: 3ms
memory: 7732kb

input:

4 4
RGWR
WWRG
WRGW
RWGR

output:

2

result:

ok single line: '2'

Test #14:

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

input:

4 4
RRRR
GGGG
WWWW
RRRR

output:

4

result:

ok single line: '4'

Test #15:

score: 0
Accepted
time: 9ms
memory: 7980kb

input:

4 4
RRRR
GGGR
WWWW
RRRR

output:

3

result:

ok single line: '3'

Test #16:

score: 0
Accepted
time: 6ms
memory: 7820kb

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: 9ms
memory: 7660kb

input:

5 5
RRGRR
RGRGW
RRWRW
RGWGW
RWWWW

output:

3

result:

ok single line: '3'

Test #18:

score: 0
Accepted
time: 9ms
memory: 7612kb

input:

6 6
RGWRGW
RRRGWR
RRWGWR
WRRRWG
GGGGGW
WWWWWW

output:

7

result:

ok single line: '7'

Test #19:

score: 0
Accepted
time: 6ms
memory: 7760kb

input:

7 10
RRRGRGWRGW
RGGGWRRGWR
RWWWWGRRGG
RGWRWWGGGW
WWRGWRGWGW
RGWWGGRGWW
RRGWWWWWWW

output:

14

result:

ok single line: '14'

Test #20:

score: 0
Accepted
time: 4ms
memory: 7996kb

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: 6ms
memory: 7748kb

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: 9ms
memory: 8040kb

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: 9ms
memory: 7628kb

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: 6ms
memory: 7748kb

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: 6ms
memory: 7604kb

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: 9ms
memory: 8016kb

input:

1 10
GGGRWWGGWW

output:

0

result:

ok single line: '0'

Test #27:

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

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: 6ms
memory: 7796kb

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: 9ms
memory: 7624kb

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: 9ms
memory: 7840kb

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: 9ms
memory: 7676kb

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: 3ms
memory: 7676kb

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: 10ms
memory: 7748kb

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: 6ms
memory: 7748kb

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: 6ms
memory: 7744kb

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: 9ms
memory: 7800kb

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: 6ms
memory: 7752kb

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: 9ms
memory: 7684kb

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: 3ms
memory: 7644kb

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: 9ms
memory: 7624kb

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: 9ms
memory: 7748kb

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: 9ms
memory: 7676kb

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: 9ms
memory: 8036kb

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: 9ms
memory: 8004kb

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: 6ms
memory: 8000kb

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: 9ms
memory: 7968kb

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: 6ms
memory: 7740kb

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: 9ms
memory: 8040kb

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: 9ms
memory: 7736kb

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: 6ms
memory: 8000kb

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: 6ms
memory: 8032kb

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: 9ms
memory: 7624kb

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: 6ms
memory: 9684kb

input:

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

output:

22

result:

ok single line: '22'

Subtask #3:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #54:

score: 67
Accepted
time: 10ms
memory: 8588kb

input:

1 3000
WRGRGRWRRRWGGRWGGWRRRRWWGGGRRRGGGGRRRWRRGRGRGWWRWRWRRWRGGWWWGRRGRGWWGRWRWWGGGWGWRWRWGGRRGRGRRRRWWGWWWGRRRWGRRGWRWGGWGWRRGRWRGWGWWGGWWRRGWGGWGRWWGGWGGGRRGGRRRGWRWGGRWRRWRGRGRWRGGRGGRRRRRGGRRGGGGWWWRGGRRWWRWGWGRRWGWGGWRRGGRWWRGGRRGRGRWRWGRGGWGWWWWWWGWGRRWGGRGGGGGWGGRRRGWRWGWRWGGRGGWGGWGRWWGWRRG...

output:

115

result:

ok single line: '115'

Test #55:

score: 0
Accepted
time: 8ms
memory: 16100kb

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: 19ms
memory: 10696kb

input:

5 3000
GRGGRRWGWWRRWGWRRGWRGWWRWRRGWRRGRWRRRGWGGRWRRRRWRRRRGWGWGRGWRRRRRWWWRRWRRGWGWRRWRRRRRRRWRRGRWRGRGRGRRRWRRGRRGWRRGWRGRWRRGWRGWWRGWWRGRRGRRGWRRGWWGRWRGWRRRGWWRRWWGGRRGRGWWGRRGWRRGWRRWGRRGRGWRRGWWRGWRRRWRWWRRRWRRGWWGWRRGWGWWRRGWWWRGWRGWRRWWRRRRRGRGRGWRGWWRGRGRRGWWRRGRGWRGRGWRRRGWGGGRGWRGWRGWRRGW...

output:

2477

result:

ok single line: '2477'

Test #57:

score: 0
Accepted
time: 21ms
memory: 17284kb

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: 952ms
memory: 209560kb

input:

1000 1000
WGRWGRRGRGWRWWWWWGWRGRGWGGRRRWGRGRGWGWGRWWGWWRRRRWWRRRRWGGGWGRWRRGGRRRRWRWGWGWRRWGGGRRRRRRWRWGWGGGRRGWRWWWWWRRRWGGRGGWGGRGRWWRWGGGGWRWWWWWWWWGGGWWGGWWRWWWGWRRRGGRWWWWGGGRWGWGRRGRGRGWRRGWGRWWGGWRWWGGGWGRRRRWRWRWRRWRWRWGRGGWGGGWGRRGRWGWWRGGGRWWGGGGWRGGGRWGGWGWWWWGWWGGWGRGGGRWRWRRRGRRGGRGWRRR...

output:

69578

result:

ok single line: '69578'

Test #59:

score: -67
Runtime Error

input:

3000 3000
RWRWRWWGRRWGWGWGWRGGRWRGRGWGGRRRRWRRWWGRGWRRRWGGRWWGRGWWGGGWRGWRGGGRRWWRRGGGWGGWRGWWWRRWRGGRRRWGGWWWGRGGRRGWRRRGWGWWWGGWGGRGGWRWWWRWGRWGRWRRWGRRGWWWGRWGRWGGGGWWGGRRRGWGRRWRGGWGGGGRGGGRWGWRRRRWWRRRRWWGRGRWRGRRWGGRGWRWGGWRWWGRGRRRGRWWGRWRGGWGRWWGGWRGWWRRGWGWRGWRWGGRWGGRWWWGWGWRGRGGWRGWRGRWRR...

output:


result: