QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#515541#3125. Dango Makermakrav13 0ms3832kbC++202.6kb2024-08-11 18:30:142024-08-11 18:30:14

Judging History

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

  • [2024-08-11 18:30:14]
  • 评测
  • 测评结果:13
  • 用时:0ms
  • 内存:3832kb
  • [2024-08-11 18:30:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second

void solve() {
    int n, m; cin >> n >> m;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    vector<vector<int>> g(2 * n * m);
    vector<int> poss(2 * n * m, 0), used(2 * n * m, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == 'G') {
                if (i > 0 && i < n - 1 && j > 0 && j < m - 1 && s[i - 1][j] == 'R' && s[i + 1][j] == 'W' && s[i][j - 1] == 'R' && s[i][j + 1] == 'W') {
                    int nm1 = ((i - 1) * m + j) * 2, nm2 = (i * m + j - 1) * 2 + 1;
                    g[nm1].pb(nm2);
                    g[nm2].pb(nm1);
                }
            } else if (s[i][j] == 'R') {
                if (i < n - 2 && s[i + 1][j] == 'G' && s[i + 2][j] == 'W') poss[(i * m + j) * 2] = 1;
                if (j < m - 2 && s[i][j + 1] == 'G' && s[i][j + 2] == 'W') poss[(i * m + j) * 2 + 1] = 1;
                if (i < n - 2 && j < m - 2 && s[i + 1][j] == 'G' && s[i + 2][j] == 'W' && s[i][j + 1] == 'G' && s[i][j + 2] == 'W') {
                    int nm1 = (i * m + j) * 2, nm2 = (i * m + j) * 2 + 1;
                    g[nm1].pb(nm2);
                    g[nm2].pb(nm1);
                }
            } else {
                if (i > 1 && j > 1 && s[i - 1][j] == 'G' && s[i - 2][j] == 'R' && s[i][j - 1] == 'G' && s[i][j - 2] == 'R') {
                    int nm1 = ((i - 2) * m + j) * 2, nm2 = (i * m + j - 2) * 2 + 1;
                    g[nm1].pb(nm2);
                    g[nm2].pb(nm1);
                }
            }
        }
    }
    int c0 = 0, c1 = 0;
    vector<int> col(2 * n * m, 0);
    auto dfs = [&](int v, auto&&dfs) -> void {
        used[v] = 1;
        if (col[v]) c1++;
        else c0++;
        for (auto &u : g[v]) {
            if (!used[u]) {
                col[u] = 1 - col[v];
                dfs(u, dfs);
            }
        }
    };
    int ans = 0;
    for (int i = 0; i < 2 * n * m; i++) {
        if (!used[i] && poss[i]) {
            c0 = 0; c1 = 0;
            dfs(i, dfs);
            ans += max(c0, c1);
        }
    }
    cout << ans << '\n';
}

signed main() {
    int tt = 1;
    #ifdef LOCAL 
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        ios::sync_with_stdio(false); 
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}

詳細信息

Subtask #1:

score: 13
Accepted

Test #1:

score: 13
Accepted
time: 0ms
memory: 3812kb

input:

1 1
G

output:

0

result:

ok single line: '0'

Test #2:

score: 13
Accepted
time: 0ms
memory: 3812kb

input:

1 2
RG

output:

0

result:

ok single line: '0'

Test #3:

score: 13
Accepted
time: 0ms
memory: 3596kb

input:

2 1
W
R

output:

0

result:

ok single line: '0'

Test #4:

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

input:

3 2
WW
RW
WR

output:

0

result:

ok single line: '0'

Test #5:

score: 13
Accepted
time: 0ms
memory: 3592kb

input:

4 4
GRRW
GWWR
WWWW
RGRG

output:

0

result:

ok single line: '0'

Test #6:

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

input:

4 4
RGRR
RRRG
GRGW
RGWW

output:

2

result:

ok single line: '2'

Test #7:

score: 13
Accepted
time: 0ms
memory: 3616kb

input:

4 4
RRGR
GRRG
WRGW
RGWW

output:

3

result:

ok single line: '3'

Test #8:

score: 13
Accepted
time: 0ms
memory: 3592kb

input:

4 4
RGWR
GGGW
WWGW
RWGW

output:

1

result:

ok single line: '1'

Test #9:

score: 13
Accepted
time: 0ms
memory: 3520kb

input:

3 3
RGW
GGG
WGW

output:

1

result:

ok single line: '1'

Test #10:

score: 13
Accepted
time: 0ms
memory: 3524kb

input:

4 1
W
R
G
W

output:

1

result:

ok single line: '1'

Test #11:

score: 13
Accepted
time: 0ms
memory: 3536kb

input:

4 4
RGWR
GWRG
WRGW
RGWR

output:

3

result:

ok single line: '3'

Test #12:

score: 13
Accepted
time: 0ms
memory: 3616kb

input:

4 4
RWWR
GWRG
WGGW
RGWR

output:

3

result:

ok single line: '3'

Test #13:

score: 13
Accepted
time: 0ms
memory: 3616kb

input:

4 4
RGWR
WWRG
WRGW
RWGR

output:

2

result:

ok single line: '2'

Test #14:

score: 13
Accepted
time: 0ms
memory: 3592kb

input:

4 4
RRRR
GGGG
WWWW
RRRR

output:

4

result:

ok single line: '4'

Test #15:

score: 13
Accepted
time: 0ms
memory: 3612kb

input:

4 4
RRRR
GGGR
WWWW
RRRR

output:

3

result:

ok single line: '3'

Test #16:

score: 13
Accepted
time: 0ms
memory: 3812kb

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

input:

5 5
RRGRR
RGRGW
RRWRW
RGWGW
RWWWW

output:

3

result:

ok single line: '3'

Test #18:

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

input:

6 6
RGWRGW
RRRGWR
RRWGWR
WRRRWG
GGGGGW
WWWWWW

output:

7

result:

ok single line: '7'

Test #19:

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

input:

7 10
RRRGRGWRGW
RGGGWRRGWR
RWWWWGRRGG
RGWRWWGGGW
WWRGWRGWGW
RGWWGGRGWW
RRGWWWWWWW

output:

14

result:

ok single line: '14'

Test #20:

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

input:

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

output:

16

result:

ok single line: '16'

Test #21:

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

input:

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

output:

16

result:

ok single line: '16'

Test #22:

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

input:

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

output:

19

result:

ok single line: '19'

Test #23:

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

input:

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

output:

7

result:

ok single line: '7'

Test #24:

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

input:

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

output:

2

result:

ok single line: '2'

Test #25:

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

input:

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

output:

0

result:

ok single line: '0'

Test #26:

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

input:

1 10
GGGRWWGGWW

output:

0

result:

ok single line: '0'

Test #27:

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

input:

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

output:

27

result:

ok single line: '27'

Test #28:

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

input:

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

output:

26

result:

ok single line: '26'

Test #29:

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

input:

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

output:

20

result:

ok single line: '20'

Test #30:

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

input:

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

output:

28

result:

ok single line: '28'

Test #31:

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

input:

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

output:

24

result:

ok single line: '24'

Test #32:

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

input:

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

output:

20

result:

ok single line: '20'

Test #33:

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

input:

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

output:

26

result:

ok single line: '26'

Test #34:

score: 0
Wrong Answer
time: 0ms
memory: 3560kb

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%