QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#192298#3125. Dango MakerCamillus#13 1ms7696kbC++202.4kb2023-09-30 14:11:122024-07-04 02:13:18

Judging History

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

  • [2024-07-04 02:13:18]
  • 评测
  • 测评结果:13
  • 用时:1ms
  • 内存:7696kb
  • [2023-09-30 14:11:12]
  • 提交

answer

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

char t[3000][3000];
bool used[3000][3000];
int sum[3000][3000];

struct Data {
    int i1 = 0, j1 = 0;
    int i2 = 0, j2 = 0;
    int i3 = 0, j3 = 0;

    Data() = default;

    static constexpr int H = 0;
    static constexpr int V = 1;

    Data(int i, int j, int t) {
        if (t == H) {
            tie(i1, j1) = tuple(i, j);
            tie(i2, j2) = tuple(i, j + 1);
            tie(i3, j3) = tuple(i, j + 2);
        } else {
            tie(i1, j1) = tuple(i, j);
            tie(i2, j2) = tuple(i + 1, j);
            tie(i3, j3) = tuple(i + 2, j); 
        }
    }

    bool check() const {
        return !used[i1][j1] && !used[i2][j2] && !used[i3][j3];
    }

    void set() const {
        used[i1][j1] = true;
        used[i2][j2] = true;
        used[i3][j3] = true;
    }

    void add() const {
        sum[i1][j1] += 1;
        sum[i2][j2] += 1;
        sum[i3][j3] += 1;
    }

    void del() const {
        sum[i1][j1] -= 1;
        sum[i2][j2] -= 1;
        sum[i3][j3] -= 1;
    }

    int get() const {
        return max({sum[i1][j1], sum[i2][j2], sum[i3][j3]});
    }
};

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];
        }
    }

    vector<Data> all;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (j + 2 < m && t[i][j] == 'R' && t[i][j + 1] == 'G' && t[i][j + 2] == 'W') {
                all.emplace_back(i, j, Data::H);
                all.back().add();
            }
            if (i + 2 < n && t[i][j] == 'R' && t[i + 1][j] == 'G' && t[i + 2][j] == 'W') {
                all.emplace_back(i, j, Data::V);
                all.back().add();
            }
        }
    }

    int ans = 0;

    while (!all.empty()) {
        auto it = min_element(all.begin(), all.end(), [](const auto &A, const auto &B) {
            return A.get() < B.get();
        });
        swap(*it, all.back());
        Data cur = all.back();
        all.pop_back();
        cur.del();
        if (cur.check()) {
            cur.set();
            ans += 1;
        }
    }

    cout << ans << '\n';
    return 0;
}

詳細信息

Subtask #1:

score: 13
Accepted

Test #1:

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

input:

1 1
G

output:

0

result:

ok single line: '0'

Test #2:

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

input:

1 2
RG

output:

0

result:

ok single line: '0'

Test #3:

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

input:

2 1
W
R

output:

0

result:

ok single line: '0'

Test #4:

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

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

input:

4 4
RGRR
RRRG
GRGW
RGWW

output:

2

result:

ok single line: '2'

Test #7:

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

input:

4 4
RRGR
GRRG
WRGW
RGWW

output:

3

result:

ok single line: '3'

Test #8:

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

input:

4 4
RGWR
GGGW
WWGW
RWGW

output:

1

result:

ok single line: '1'

Test #9:

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

input:

3 3
RGW
GGG
WGW

output:

1

result:

ok single line: '1'

Test #10:

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

input:

4 1
W
R
G
W

output:

1

result:

ok single line: '1'

Test #11:

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

input:

4 4
RGWR
GWRG
WRGW
RGWR

output:

3

result:

ok single line: '3'

Test #12:

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

input:

4 4
RWWR
GWRG
WGGW
RGWR

output:

3

result:

ok single line: '3'

Test #13:

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

input:

4 4
RGWR
WWRG
WRGW
RWGR

output:

2

result:

ok single line: '2'

Test #14:

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

input:

4 4
RRRR
GGGG
WWWW
RRRR

output:

4

result:

ok single line: '4'

Test #15:

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

input:

4 4
RRRR
GGGR
WWWW
RRRR

output:

3

result:

ok single line: '3'

Test #16:

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

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

input:

5 5
RRGRR
RGRGW
RRWRW
RGWGW
RWWWW

output:

3

result:

ok single line: '3'

Test #18:

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

input:

6 6
RGWRGW
RRRGWR
RRWGWR
WRRRWG
GGGGGW
WWWWWW

output:

7

result:

ok single line: '7'

Test #19:

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

input:

7 10
RRRGRGWRGW
RGGGWRRGWR
RWWWWGRRGG
RGWRWWGGGW
WWRGWRGWGW
RGWWGGRGWW
RRGWWWWWWW

output:

14

result:

ok single line: '14'

Test #20:

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

input:

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

output:

15

result:

wrong answer 1st lines differ - expected: '16', found: '15'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%